英文文档
ascii(object)
As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using \x, \u or \U escapes. This generates a string similar to that returned by repr() in Python 2.
ascii()
1、返回一个可打印的对象字符串方式表示,如果是非ascii字符就会输出\x,\u或\U等字符来表示。与python2版本里的repr()是等效的函数。
>>> ascii(1)
'1'
>>> ascii('$')
"'$'"
>>> ascii(999999)
'999999'
>>> ascii('中国') #非ascii字符
"'\\u4e2d\\u56fd'"
小结
希望通过上面的操作能帮助大家。如果你有什么好的意见,建议,或者有不同的看法,我都希望你留言和我们进行交流、讨论。
欢迎关注微信公众号,访问更多精彩:AiryData。
如需转载,请联系授权,谢谢合作。