#小白1.3实例练习python温度转换一直无法运行
#老师演示的代码如下
我写的如下:
#tempconvert.py
TempStr = input("temperature value with signs:")
if TempStr[-1] in ['F','f']:
C = (eval(tempstr[0:-1]) - 32)/1.8
print("the converted temperature is{:.2f}C".format(C))
elif TempStr[-1] in ['C','c']:
F = 1.8*eval(tempstr[0:-1]) + 32
print("the converted temperature is{:.2f}F".format(F))
else:
print("filed to output")
因为反复修改还是运行不成功,不知道是不是输入法的问题,就把里面的一些描述改成全英文了,甚至还直接复制了他人写的代码试运行,也不行
然而报错一直如下
Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
===================== RESTART: D:/python/tempconvert.py =====================
temperature value with signs:85f
Traceback (most recent call last):
File "D:/python/tempconvert.py", line 2, in <module>
TempStr = input("temperature value with signs:")
File "<string>", line 1
85f
^
SyntaxError: unexpected EOF while parsing
>>>
请求解答是什么问题