将数字除以包含值的字符串?

时间:2018-02-26 19:44:23

标签: python string integer operators


我定义,让我们说E=10我尝试A=1/E(在python中),然后python告诉我:

TypeError: unsupported operand type(s) for /: 'int' and 'str'

我该怎么办呢?

谢谢!

1 个答案:

答案 0 :(得分:2)

>>> E=10.0
>>> A=1/E
>>> print(A)

0.1