weixin_38190551
2019-01-14 00:21python温度转换提示“TypeError: string indices must be integers”
5TempStr=(input("请输入带有符号的温度值:"))
if TempStr[-1] in ['F','f']:
C = (eval(TempStr[0,-1] - 32))/1.8
print("转换后的温度是{:.2f}C".format(C))
elif TempStr[-1] in['C','c']:
F = 1.8*eval(TempStr[0,-1]) + 32
print("转换后的温度是{:.2f}F".format(F))
else:
print("输入错误")
TypeError: string indices must be integers
环境python3.7.2。麻烦大神帮忙看看,新手。
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- PHP-> Python JSON问题
- json
- python
- php
- 3个回答
- 爬取途牛机票信息报错--TypeError: string indices must be integers
- python
- json
- list
- 1个回答
- 急求:Json无法从dic-list-dic结构的字典中提取出数据
- python
- 1个回答
- python温度转换提示“TypeError: string indices must be integers”
- python
- 开发语言
- 1个回答