python变量作用域
时间: 2023-10-12 09:04:15 浏览: 104
python变量的作用域是什么
Python变量作用域一般有四种,分别是局部变量(Local)、嵌套变量(Enclosed)、全局变量(Global)和内置变量(Built-in)。局部变量是在函数内部定义的变量,只在函数内部有效。嵌套变量是在函数嵌套中使用的变量,它可以在嵌套函数中访问外层函数的变量。全局变量是在整个程序中都有效的变量,可以在任何地方访问。内置变量是Python中已经定义好的变量,如int、str等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [什么是Python变量作用域](https://download.csdn.net/download/weixin_38703123/12851347)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Python之变量作用域](https://blog.csdn.net/qq_44690947/article/details/124579603)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文