英文:
How to represent Unicode encoded strings in Python?
问题
I am translating a program from Java to Python.
In the source code of the Java program, the strings use the "\u000x" encoding for a few characters. As I understand, this is the unicode representation of the character and x is a hexadecimal code for that character.
In Java program the string is declared as:
data = "~\\GJ_F^A\u001eXJ]NK\u0018!"
How do I represent this in Python?
The above string has two encoded characters:
\u001e
\u0018
Thanks.
英文:
I am translating a program from Java to Python.
In the source code of the Java program, the strings use the "\u000x" encoding for a few characters. As I understand, this is the unicode representation of the character and x is a hexadecimal code for that character.
In Java program the string is declared as:
data = "~\\GJ_F^A\u001eXJ]NK\u0018!"
How do I represent this in Python?
The above string has two encoded characters:
\u001e
\u0018
Thanks.
答案1
得分: 1
Python 也支持 Unicode 转义代码。 这是有效的 Python 代码:
data = "~\\GJ_F^A\u001eXJ]NK\u0018!"
英文:
Python also has Unicode escape codes. This is valid python:
data = "~\\GJ_F^A\u001eXJ]NK\u0018!"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论