Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有基于字符串 len 的十进制数。如何将其转换为 \u0030(0030 4 位是字符串的 len)?
例子:
char = 'teststring'
有 10 个字符
然后转换为
u'\u0010teststring'
我用于
char = char.encode('utf-16le')
你正在寻找unichr().
unichr()
>>> unichr(10) u'\n' >>> u'\u000a' u'\n'