python socket 질문있습니다

익명 사용자의 이미지

언어는 python입니다
값은b' C \xb5\xe5\xb6\xf3\xc0\xcc\xba\xea\xc0\xc7 \xba\xbc\xb7\xfd: OS\r\n \xba\xbc\xb7\xfd \xc0\xcf\xb7\xc3 \xb9\xf8\xc8\xa3: F40E-AD49\r\n\r\n C:\\python_server \xb5\xf0\xb7\xba\xc5\xcd\xb8\xae\r\n\r\n2020-12-01 \xbf\xc0\xc0\xfc 12:10 .\r\n2020-12-01 \xbf\xc0\xc0\xfc 12:10 ..\r\n2020-12-03 \xbf\xc0\xc0\xfc 12:24 823 back_c.py\r\n2020-12-03 \xbf\xc0\xc0\xfc 12:24 802 back_s.py\r\n2020-11-30 \xbf\xc0\xc8\xc4 05:49 798 client.py\r\n2020-12-01 \xbf\xc0\xc0\xfc 01:33 740 server.py\r\n 4\xb0\xb3 \xc6\xc4\xc0\xcf 3,163 \xb9\xd9\xc0\xcc\xc6\xae\r\n 2\xb0\xb3 \xb5\xf0\xb7\xba\xc5\xcd\xb8\xae 167,106,060,288 \xb9\xd9\xc0\xcc\xc6\xae \xb3\xb2\xc0\xbd\r\n'
이런식으로 출력이 됩니다
이것을 다시 str형식으로 바꾸고 싶은데 방법이 있을까요?
decode, encode 사용을해도 'utf-8' codec can't decode byte 0xb5 in position 3: invalid start byte 에러가 뜹니다..ㅠ

File attachments: 
첨부파일 크기
Image icon 소스 코드입니다.153.81 KB
chanik의 이미지

파이썬 3.4에서 했습니다.

>>> buf = b' C \xb5\xe5\xb6\xf3\xc0\xcc\xba\xea\xc0\xc7 \xba\xbc\xb7\xfd: OS\r\n \xba\xbc\xb7\xfd \xc0\xcf\xb7\xc3 \xb9\xf8\xc8\xa3: F40E-AD49\r\n\r\n C:\\python_server \xb5\xf0\xb7\xba\xc5\xcd\xb8\xae\r\n\r\n2020-12-01 \xbf\xc0\xc0\xfc 12:10 .\r\n2020-12-01 \xbf\xc0\xc0\xfc 12:10 ..\r\n2020-12-03 \xbf\xc0\xc0\xfc 12:24 823 back_c.py\r\n2020-12-03 \xbf\xc0\xc0\xfc 12:24 802 back_s.py\r\n2020-11-30 \xbf\xc0\xc8\xc4 05:49 798 client.py\r\n2020-12-01 \xbf\xc0\xc0\xfc 01:33 740 server.py\r\n 4\xb0\xb3 \xc6\xc4\xc0\xcf 3,163 \xb9\xd9\xc0\xcc\xc6\xae\r\n 2\xb0\xb3 \xb5\xf0\xb7\xba\xc5\xcd\xb8\xae 167,106,060,288 \xb9\xd9\xc0\xcc\xc6\xae \xb3\xb2\xc0\xbd\r\n'
>>> buf.decode('cp949')
' C 드라이브의 볼륨: OS\r\n 볼륨 일련 번호: F40E-AD49\r\n\r\n C:\\python_server 디렉터리\r\n\r\n2020-12-01 오전 12:10 .\r\n2020-12-01 오전 12:10 ..\r\n2020-12-03 오전 12:24 823 back_c.py\r\n2020-12-03 오전 12:24 802 back_s.py\r\n2020-11-30 오후 05:49 798 client.py\r\n2020-12-01 오전 01:33 740 server.py\r\n 4개 파일 3,163 바이트\r\n 2개 디렉터리 167,106,060,288 바이트 남음\r\n'
>>> print(buf.decode('cp949'))
 C 드라이브의 볼륨: OS
 볼륨 일련 번호: F40E-AD49
 
 C:\python_server 디렉터리
 
2020-12-01 오전 12:10 .
2020-12-01 오전 12:10 ..
2020-12-03 오전 12:24 823 back_c.py
2020-12-03 오전 12:24 802 back_s.py
2020-11-30 오후 05:49 798 client.py
2020-12-01 오전 01:33 740 server.py
 4개 파일 3,163 바이트
 2개 디렉터리 167,106,060,288 바이트 남음
 
>>>

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.