The World Wide Web, restored to 800 pixels of glory.
GeezerVison is showing www.runoob.com — Python repr() 函数 | 菜鸟教程
Python 内置函数
repr() 函数将对象转化为供解释器读取的形式。
以下是 repr() 方法的语法:
repr(object)
返回一个对象的 string 格式。
以下展示了使用 repr() 方法的实例:
桂月
oga***[email protected]
repr() 方法可以将读取到的格式字符,比如换行符、制表符,转化为其相应的转义字符。
示例:
# coding=UTF-8 s="物品\t单价\t数量\n包子\t1\t2" print(s) print(repr(s))
运行结果:
物品 单价 数量 包子 1 2 '物品\t单价\t数量\n包子\t1\t2'
取消