python - 以 10 为基数的 int() 的文字无效

标签 python

我编写的货币转换程序继续出现此错误

baht = raw_input("enter baht")
usd = int(baht) / (30.94)
print "%r baht equals %r usd" % (baht, usd)

最佳答案

问题:

  1. 使用 float(baht) 作为 Bath,它可能是利率,而不是整数。
  2. 不要使用逗号 (,) 作为小数点分隔符,而是使用点 (.)

关于python - 以 10 为基数的 int() 的文字无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10096450/

相关文章:

python - 忽略正则表达式中带有空格的注释

python - django if 标签和 ifequal 标签无法正常工作

python - 如何在Python中改变Delaunay点的颜色?

python - python中的表格小部件问题

python - LSTM在Keras中的实现

python - 在 Django 序列化程序中,如何根据 View 参数设置外键字段?

Python Kivy - 下划线在标签中不起作用

python - 在类内部分配之前引用的局部变量

Python 子进程 : read returncode is sometimes different from returned code

python - 计算每个时间步长的可变长度输出的成本