成员 1594
帖子 480
+ 加入
下载掌阅iReader客户端
wszzzwdbb
LV12 2018-10-13
帮我看一下哪里错了
#TempConvert.py
TempStr = input("请输入带有符号的温度:")
if TempStr[-1] in ['F','f']:
C = (eval(TempStr[θ:-1]) - 32)/1.8
print("转换后的温度是{:.2f}C".format(C))
elif TempStr[-1] in ['C','c']:
F = 1.8*eval(TempStr[θ:-1]) + 32
print("转换后的温度是{:.2f}F".format(F))
else:
print("输入格式错误")
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
========= RESTART: C:\Program Files (x86)\Python35-32\TempConvert.py =========
请输入带有符号的温度:32C
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\TempConvert.py", line 7, in
F = 1.8*eval(TempStr[θ:-1]) + 32
NameError: name 'θ' is not defined
>>>
========= RESTART: C:\Program Files (x86)\Python35-32\TempConvert.py =========
请输入带有符号的温度:76F
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\TempConvert.py", line 4, in
C = (eval(TempStr[θ:-1]) - 32)/1.8
NameError: name 'θ' is not defined
>>>
#TempConvert.py
TempStr = input("请输入带有符号的温度:")
if TempStr[-1] in ['F','f']:
C = (eval(TempStr[θ:-1]) - 32)/1.8
print("转换后的温度是{:.2f}C".format(C))
elif TempStr[-1] in ['C','c']:
F = 1.8*eval(TempStr[θ:-1]) + 32
print("转换后的温度是{:.2f}F".format(F))
else:
print("输入格式错误")
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
========= RESTART: C:\Program Files (x86)\Python35-32\TempConvert.py =========
请输入带有符号的温度:32C
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\TempConvert.py", line 7, in
F = 1.8*eval(TempStr[θ:-1]) + 32
NameError: name 'θ' is not defined
>>>
========= RESTART: C:\Program Files (x86)\Python35-32\TempConvert.py =========
请输入带有符号的温度:76F
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\TempConvert.py", line 4, in
C = (eval(TempStr[θ:-1]) - 32)/1.8
NameError: name 'θ' is not defined
>>>