英文文檔:
ascii(object)
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 by repr() in Python 2.
說明:
- 返回一個(gè)可打印的對(duì)象字符串方式表示傻铣,如果是非ascii字符就會(huì)輸出\x盐碱,\u或\U等字符來表示信峻。與python2版本里的repr()是等效的函數(shù)是趴。
>>> ascii(1)
'1'
>>> ascii('&')
"'&'"
>>> ascii(9000000)
'9000000'
>>> ascii('中文') #非ascii字符
"'\\u4e2d\\u6587'"