我是python和unicode的新手。我试图在python中生成一个随机的unicode字符串。这就是我想出的:
def randomUnicodeStr(self, ustart, uend):
'''Generate a random unicode string whose length is strlen and whose unicode characters are in range ustart, uend'''
strlen = 5
uchars = [random.choice(range(ustart, uend+1)) for _ in range (strlen)]
ustr = u''
for uc in uchars:
ustr += unichr(uc)
#for i in range(len(ustr)):
# print "Py char " + str(i) + " = " + str(ord(ustr[i]))
return ustr
我无法从python文档中收集此信息,但上面的ustr
使用了哪种编码?