## 学习要点

### - 初步了解for 和if

``````s = '1F'
``````
``````s.strip('F')
``````
``````'1'
``````
``````print('欢迎使用万能单位转换器'.center(30,'*'))
print(k,v)
choose = input('请输入转换类型：')
if choose == 'T':
temp = input('请输入温度：')
# Tf = (9/5) * Tc + 32
temp = temp.strip('T').strip('C')
Tf = (9 / 5) * float(temp) +32
print(f'{Tf} = (9 / 5) * {temp} +32')
else:
print('开发中。。。')

``````
``````*********欢迎使用万能单位转换器**********
T 温度转换
L 长度转换
C 货币转换

50.0 = (9 / 5) * 10 +32
``````
``````print('欢迎使用万能单位转换器'.center(30,'*'))
print(k,v)
choose = input('请输入转换数值（数值+单位，如1C）：')
choose = choose.upper()
if choose.endswith('T'):
choose = choose.strip('T')
choose = float(choose)
Tf = (9 / 5) * choose + 32 # 与浮点数运算必须是浮点数类型
print(f'{Tf} = (9 / 5) * {choose} + 32')
elif choose.endswith('C'):
# Tc = (5 /9) * (Tf - 32)
choose = choose.strip('C')
Tc = (5 / 9) * (float(choose) - 32)
print(f'{Tc} = (5 / 9) * ({choose} -32)')
print(f'最终结果是：{Tc}°')
else:
print('开发中。。。')

``````
``````*********欢迎使用万能单位转换器**********
T 温度转换
L 长度转换
C 货币转换

-12.222222222222223 = (5 / 9) * (10 -32)

``````