我在我的代码上收到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
对于那些投票关闭这个问题,我米不太确定这是一个简单的印刷错误。文档字符串应该不是很明显因为大多数新用户会认为文档字符串是一种荣耀的评论,并没有缩进限制。作为证据,请看[@BenWhaley](http://stackoverflow.com/a/21805104/1399279)的回答,他称这个文档字符串是一个评论(它说明了他们可以很容易被混淆。) – SethMMorton