Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python错误消息_Python - Fatal编程技术网

Python错误消息

Python错误消息,python,Python,如何修复此错误: Traceback (most recent call last): File "C:\Users\Tony\Desktop\Python\4.py", line 64, in print "YOU PAY: $",(pc-total) TypeError: unsupported operand type(s) for -: 'str' and 'float' 其中一个是浮点数,pc或total,另一个是字符串 由于python是强类型的,您需要将字符串转换为浮

如何修复此错误:

Traceback (most recent call last):
  File "C:\Users\Tony\Desktop\Python\4.py", line 64, in 
    print "YOU PAY: $",(pc-total)
TypeError: unsupported operand type(s) for -: 'str' and 'float'

其中一个是浮点数,
pc
total
,另一个是字符串

由于python是强类型的,您需要将字符串转换为浮点,例如:

print "YOU PAY $",(float(pc) - total)

其中一个是浮点数,
pc
total
,另一个是字符串

由于python是强类型的,您需要将字符串转换为浮点,例如:

print "YOU PAY $",(float(pc) - total)

这不仅是一个编程问题,而且您正在Windows上运行该程序。错误的站点。这不仅是一个编程问题,而且您正在Windows上运行该程序。错误的站点。