小编Usu*_*ive的帖子

格式字符不受支持?

我正在尝试使用带有浮点格式器的行将行打印到2个小数点,如下所示:

    print "You have a discount of 20% and the final cost of the item is'%.2f' dollars." % price
Run Code Online (Sandbox Code Playgroud)

但是当我这样做时,会出现以下错误:

ValueError:索引27处不支持的格式字符'a'(0x61)

这是什么意思,我该如何防止它发生?

python python-2.7

5
推荐指数
2
解决办法
7985
查看次数

标签 统计

python ×1

python-2.7 ×1