코드에 SyntaxError 'return outside function'
오류가 표시됩니다. 나는 이것에 관해서 어떤 도움을 주셔서 감사하겠습니다.Python : SyntaxError 함수의 외부에서 'return'오류가 발생했습니다.
def temp(T, from_unit, to_unit) : # Function for temperature
""" Convert between Fahrenheit, Celsius, or Kelvin. Where from_unit and to_unit are temperature units, either 'F' (or 'f')
for Fahrenheit, or 'C' (or 'c') for Celsius, or 'K'(or 'k') for Kelvin; and T is a temperature number (of float) for the
unit from_unit """
if from_unit == to_unit:
return T
을 잃게됩니다 이것은 단순한 타이포그래피 오류라고 확신하지는 못합니다. docstring이 있어야하는 것은 분명하지 않습니다. 대부분의 새로운 사용자는 들여 쓰기가 제한되지 않은 영광스러운 주석으로 문서화 문자열을 생각할 것이기 때문에 코드와 동일한 수준으로 움푹 들어가 있습니다. 증거를 얻으려면 문서 문자열에 주석을 달아 주었던 [@BenWhaley의 대답] (http://stackoverflow.com/a/21805104/1399279)을 살펴보십시오.이 주석은 사람들이 쉽게 혼동 될 수 있음을 보여줍니다. – SethMMorton