gpt4 book ai didi

python - 为什么在这种情况下不需要 global 关键字?

转载 作者:行者123 更新时间:2023-11-28 19:07:46 24 4
gpt4 key购买 nike

<分区>

cache = {}
def func():
cache['foo'] = 'bar'
print cache['foo']

输出

bar

为什么这行得通,为什么不需要使用 global 关键字?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com