我有以下代码(假设我逐行输入IDLE)
# -*- coding: utf-8 -*-
s = u"My Currency is - £"
s
print s
对于--s
我正在输出-u'My Currency is - \xa3'
对于--print s
我正在输出-u'My Currency is - £'
有什么区别 ?为什么我得到不同的输出?
在Python中,print
显示__str__
参数的结果,该结果可能与有所不同__repr__
。有关更多信息,请参见此处:Python中__str__和__repr__之间的区别
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句