如何修复错误:语法错误:无效语法
嘿,我只是在多年没有用它编程之后又重新开始使用它了。但我想把一些简单的脚本组合在一起,看看我是否记住了到目前为止的所有功能。现在我得到了这个代码:
选择 | 换行 | 行号
- #!/usr/bin/python
- # A program developed to see if the temperature is Celcius or Farhenheit
- # and than convert it to the other in a more user friendly manner
- import os, sys
- import math
- def far(temp):
- Celcius = ((temp - 32) * 5) / 9
- Kelvin = Celcius + 273.15
- def cel(temp):
- Far = (temp * 1.8) + 32
- Kelvin = temp + 273.15
- def kelvin(temp):
- Celcius = temp + 273.15
- Far = (Celcius * 1.8) + 32
- human = raw_input("Is your temperature in Fahrenheit (f), Celcius (c), or Kelvin (k) --> ")
- temp1 = int(raw_input("What is your temperature --> ")
- if human=="f":
- far(temp1)
- print "Your temperature is %s in Celcius and %s in Kelvin" % Celcius,Kelvin
- if human=="c":
- cel(temp1)
- print "Your temperature is %s in Fahrenheit and %s in Kelvin" % Far,Kelvin
- if human=="k":
- kelvin(temp1)
- print "Your temperature is %s in Celcius and %s in Fahrenheit" % Celcius,Far
我希望用户定义他们有哪种温度,然后程序输出其他温度。但到目前为止,我得到的只是第28行的语法错误:
选择 | 换行 | 行号
- File "temp2.py", line 28
- if human=="f":
- ^
- SyntaxError: invalid syntax
有谁有什么想法吗?