ascii()返回一个字符串对象。
ascii()的参数只能有一个。
如果参数中有非ascii字符,会用 \u,\U,\x 来替代。
ascii()和Python2中repr()等效
下面看看例子:
>>> ascii('hello') "'hello'" >>> ascii(123) '123' >>> ascii([1,2]) '[1, 2]' >>> ascii('中国') "'\\u4e2d\\u56fd'"
博客园 © 2004-2025 浙公网安备 33010602011771号 浙ICP备2021040463号-3