Manual
As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned byrepr() using \x, \u or \U escapes. This generates a string similar to that returned byrepr() in Python 2.
直译
与repr()类似,返回包含一个可打印表示的对象的字符串,但字符串中的非ASCII(non-ASCII)字符通过使用\x, \u或\U转义符进行转义。生成的字符串与Python 2中的repr()的返回值相近。
实例
>>> ascii(10)
'10'
>>> ascii(900000)
'900000'
>>> ascii('100')
"'100'"
>>> ascii([0, 1, 2, 3])
'[0, 1, 2, 3]'
>>> ascii('我去年买了个表')
"'\\u6211\\u53bb\\u5e74\\u4e70\\u4e86\\u4e2a\\u8868'"