标签:sid fun script use cti UNC ble 定义函数 def
定义函数的语法:
def 函数名(参数)
(语句)
1 #函数和变量
2 #函数里的变量与脚本里的变量是没有联系的。
3 def cheese_and_crackers(cheese_count,boxes_of_crackers):
4 print(f"You have {cheese_count} cheese!")
5 print(f"You have {boxes_of_crackers} boxes of crackers!")
6 print("Man that‘s enough for a party!")
7 print("Get a blanket.\n") #blanket :毛毯
8
9
10 print("We can just give the function numbers directly: ")
11 cheese_and_crackers(20,30)
12
13
14 print("OR, We can use variables from our script:")
15 amount_of_cheese = 10
16 amount_of_crackers =50
17 cheese_and_crackers(amount_of_cheese,amount_of_crackers)
18
19
20 print("We can even do math inside too: ")
21 cheese_and_crackers(10 + 20, 5 + 6)
22
23
24 print("And we can combine the two, variable and math: ")
25 cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)
标签:sid fun script use cti UNC ble 定义函数 def
原文地址:https://www.cnblogs.com/lsc666js/p/13334714.html