【发布时间】:2013-07-02 06:19:32
【问题描述】:
我正在尝试学习如何在 Python 3 中使用 ascii 函数。
文档内容
ascii(对象)
作为 repr(),返回一个包含可打印表示的字符串 对象,但转义返回的字符串中的非 ASCII 字符 repr() 使用 \x、\u 或 \U 转义。这会生成一个类似于 在 Python 2 中由 repr() 返回。
但是,当我尝试使用 print ascii("c") 时,我收到错误:
print ascii("c")
^
SyntaxError: invalid syntax
如何使用这个功能?
【问题讨论】:
-
print是 Python 3 中的一个函数。
标签: python python-3.x ascii