[Python] print() 되는대로 string으로 변환하는 함수
[code]
def print2string(*args, **kwargs):
with io.StringIO() as o:
print(*args, file=o, **kwargs)
result = o.getvalue()
return result
[/code]
제목 그대로 print()한 결과물 그대로 string으로 변환하는 함수에요~ ^^
테스트해보면 리스트의 괄호 등이 그대로 문자열로 변환되는 것을 확인할 수 있어요 :)
댓글 2개
3년 전
오! 감사합니다!
3년 전
멋지네요. 감사합니다.
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 5276 | 2년 전 | 1336 | |||
| 5275 | 2년 전 | 1405 | |||
| 5274 | 기타 | 2년 전 | 821 | ||
| 5273 | JavaScript |
swallow
|
2년 전 | 1053 | |
| 5272 | node.js |
swallow
|
2년 전 | 748 | |
| 5271 | JavaScript |
swallow
|
2년 전 | 1498 | |
| 5270 | PHP |
swallow
|
2년 전 | 848 | |
| 5269 | node.js |
swallow
|
2년 전 | 684 | |
| 5268 | node.js |
swallow
|
2년 전 | 1217 | |
| 5267 | PHP |
swallow
|
2년 전 | 1599 | |
| 5266 | MySQL |
swallow
|
2년 전 | 1095 | |
| 5265 | PHP |
swallow
|
2년 전 | 2035 | |
| 5264 | JavaScript |
swallow
|
2년 전 | 861 | |
| 5263 | 기타 |
swallow
|
2년 전 | 2984 | |
| 5262 | 기타 |
swallow
|
2년 전 | 670 | |
| 5261 | node.js |
swallow
|
2년 전 | 1065 | |
| 5260 | JavaScript |
swallow
|
2년 전 | 1514 | |
| 5259 | node.js |
swallow
|
2년 전 | 736 | |
| 5258 | node.js |
swallow
|
2년 전 | 1749 | |
| 5257 | node.js |
swallow
|
2년 전 | 1300 | |
| 5256 | PHP |
swallow
|
2년 전 | 1941 | |
| 5255 | node.js |
swallow
|
2년 전 | 692 | |
| 5254 | PHP |
swallow
|
2년 전 | 3015 | |
| 5253 | node.js |
swallow
|
2년 전 | 680 | |
| 5252 | 정규표현식 |
swallow
|
2년 전 | 625 | |
| 5251 | node.js |
swallow
|
2년 전 | 882 | |
| 5250 | PHP |
swallow
|
2년 전 | 1116 | |
| 5249 | node.js |
swallow
|
2년 전 | 1066 | |
| 5248 | PHP |
swallow
|
2년 전 | 1411 | |
| 5247 | node.js |
swallow
|
2년 전 | 1018 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기