IT
[python]바이트를 문자열로 변환합니다
바이트를 문자열로 변환합니다 질문 이 코드를 사용하여 외부 프로그램에서 표준 출력을 얻습니다.>>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] Communicate () 메서드는 바이트 배열을 반환합니다.>>> command_stdout b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file2\n' 그러나, 나는 출력을 정상적인 파이썬 문자열로 일하고 싶습니다.그래서 내가 이것을 인쇄 할 수 있었기 때문에 :>>> print(command_stdo..
2022. 4. 4. 13:55
최근댓글