ascii()返回一个字符串对象。

ascii()的参数只能有一个。

如果参数中有非ascii字符,会用 \u,\U,\x 来替代。

ascii()和Python2中repr()等效

下面看看例子:

>>> ascii('hello')
"'hello'"
>>> ascii(123)
'123'
>>> ascii([1,2])
'[1, 2]'
>>> ascii('中国')
"'\\u4e2d\\u56fd'"

 

相关文章:

  • 2021-06-08
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-01-07
  • 2021-10-02
相关资源
相似解决方案