简体   繁体   English

python3:如何将具有Unicode编码的字符串转换为字母字符串

[英]python3: How to convert a string with Unicode encoding to a string of letters

In Python3, how do I convert '\\\© PNG' to '\© PNG' (or '© PNG' )? 在Python3中,如何将'\\\© PNG'转换为'\© PNG' (或'© PNG' )?

For Java, there is Apache Commons Lang to decode it. 对于Java,有Apache Commons Lang对其进行解码。

I don't know how to do in Python3. 我不知道如何在Python3中做。

This should work for you. 这应该为您工作。

string = '\\u00A9 PNG'
print (string.encode('utf8').decode('unicode-escape'))

output: 输出:

© PNG ©PNG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM