目录html
点击上面连接,安装python和开发环境python
temp=input("请输入温度") if temp[-1:]=='C': F=eval(temp[:-1])*1.8+32 printf(str(F)+'F') elif temp[-1:]=='F': C=(eval(temp[:-1])-32)/1.8 printf(C)
T = input("输入时间") if T[-3:] == 'min': d = eval(T[:-3]) / 60 / 24 print(str(d) + 'd') elif T[-1:] == 'd': min = eval(T[:-1]) * 60 * 24 print(str(int(min)) + 'min') elif T[-4:] == 'week': d = eval(T[:-4]) *7 print(str(int(d)) + 'd') else : print("输入错误,请从新输入")
eval主要用于把字符串里的值进行运算后取出来,如:ide
eval('abcd')=abcdspa
eval('123')=123code
temp = '456123789' print(temp[:]) print(temp[-1]) print(temp[-3:-1]) print(temp[-3:]) print(temp[:-1]) print(temp[-7:-2])
s='nick handsome' print(s[:8:1]) # nick han #从前日后,输出前八个 print(s[:8:2]) # nc a #从前日后,跳一个输出 print(s[:8:-1]) # emos # 从右向左,从后往前输出,第八个字符以后的 print(s[-4::-1]) #从右向左,依次输出