我正在尝试使用带有浮点格式器的行将行打印到2个小数点,如下所示:
print "You have a discount of 20% and the final cost of the item is'%.2f' dollars." % price
但是当我这样做时,会出现以下错误:
ValueError:索引27处不支持的格式字符'a'(0x61)
这是什么意思,我该如何防止它发生?
python python-2.7
python ×1
python-2.7 ×1