You need to know the encoding of the input string. There is no reliable universal solution.
The encoding should be available from the source of the input string. For instance, if you're taking text from a web page, the encoding should be indicated as part of the HTTP Content-EncodingType should be indicated, either as a HTTP response header from the server or as <meta> tag in the page source.
Once you know the encoding, use the decode method.
This string appears to be Shift-JIS:
>>> x = '\x83h\x83L\x83\x85\x83\x81\x83\x93\x83g\x82\xf0\x96|\x96\xf3\x82\xb5\x82\xdc\x82\xb7'
>>> print x.decode( "shift-jis" )
ドキュメントを翻訳します
You need to know the encoding of the input string. There is no reliable universal solution.
The encoding should be available from the source of the input string. For instance, if you're taking text from a web page, the Content-Encoding should be indicated either as a HTTP response header from the server or as <meta> tag in the page source.
Once you know the encoding, use the decode method.
This string appears to be Shift-JIS:
>>> x = '\x83h\x83L\x83\x85\x83\x81\x83\x93\x83g\x82\xf0\x96|\x96\xf3\x82\xb5\x82\xdc\x82\xb7'
>>> print x.decode( "shift-jis" )
ドキュメントを翻訳します
You need to know the encoding of the input string. There is no reliable universal solution.
The encoding should be available from the source of the input string. For instance, if you're taking text from a web page, the encoding should be indicated as part of the HTTP Content-Type, either as a HTTP response header from the server or as <meta> tag in the page source.
Once you know the encoding, use the decode method.
This string appears to be Shift-JIS:
>>> x = '\x83h\x83L\x83\x85\x83\x81\x83\x93\x83g\x82\xf0\x96|\x96\xf3\x82\xb5\x82\xdc\x82\xb7'
>>> print x.decode( "shift-jis" )
ドキュメントを翻訳します
You need to know the encoding of the input string. There is no reliable universal solution.
The encoding should be available from the source of the input string. For instance, if you're taking text from a web page, the Content-Encoding should be indicated either as a HTTP response header from the server or as <meta> tag in the page source.
Once you know the encoding, use the decode method.
This string appears to be Shift-JIS:
>>> x = '\x83h\x83L\x83\x85\x83\x81\x83\x93\x83g\x82\xf0\x96|\x96\xf3\x82\xb5\x82\xdc\x82\xb7'
>>> print x.decode( "shift-jis" )
ドキュメントを翻訳します