9 月 162020
 
#函数print()与关键字return
def fahrenheit_converter(C):
    fahrenheit = C * 9 / 5 + 32
#    return fahrenheit + 'F'
#禁用自定义函数的return返回,调用print()函数
    print(str(fahrenheit) + 'F')

#开始调用自定义函数
C2F = fahrenheit_converter(35)
print(C2F)
#输出的结果,第一行为指定的print()函数的打印输出
#第二行为调用fahrenheit_converter()函数的输出,函数中无return关键字,所以返回值为空
#Python中的return是可选的
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
95.0F
None
PS C:\Users\harveymei>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)