字典当作参数以后的一些用法:
dic={'abc':123,'aaa':333,'wer':334} def text_dic(**dd): for a,b in dd.items():# a 代表键 ,b代表值 print(a,b) text_dic(**dic)
#输出字典中的键:
def text_dic(**dd):
for key in text_dic:#key为键
print(key)
text_dic(**dic)
#输出字典中键的值:
def text_dic(**dd):
for value in text_dic.keys():#value为值
print(value)
text_dic(**dic)
变量的作用域:
全局变量:
全局变量的作用域当然是全局的随时可调用,他要是和局部变量冲突时,局部变量优先
局部变量:
在python中局部变量不可以改变全局变量。
当然如果你想在局部改全局变量的话,你可以先声明这个变量是全局变量globle,然后在进行更改