9 月 222020
 
#自定义函数,重量克转化为千克
def g2kg(g):
    kg = g / 1000
    return str(kg) + 'kg'

#调用函数并赋值变量
result = g2kg(2500)
#打印变量
print(result)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
2.5kg
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)