【发布时间】:2016-01-25 01:39:44
【问题描述】:
>>>print('You say:{0:r}'.format("i love you"))
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
print('You say:{0:r}'.format("i love you"))
ValueError: Unknown format code 'r' for object of type 'str'
我只是在python2中使用%r(repr()),它应该可以在python3.5中使用。为什么会这样?
另外,我应该使用什么格式?
【问题讨论】:
标签: python string python-3.x format