[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개