惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
F
Fortinet All Blogs
D
Docker
博客园 - 司徒正美
腾讯CDC
Recent Announcements
Recent Announcements
The Cloudflare Blog
B
Blog RSS Feed
GbyAI
GbyAI
T
Tailwind CSS Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志

噜啦 - 函数

函数变量的作用域 - 噜啦 函数的可变长参数 - 噜啦 函数的可变长参数 - 噜啦 函数的定义和常用操作 && 课堂练习 - 噜啦 函数的定义和常用操作 && 课堂练习 - 噜啦
函数变量的作用域 - 噜啦
博主: 噜啦 · 2019-09-18 · via 噜啦 - 函数

代码

var = 123
def func():
    var = 456
    print(var)

func()
print(var)

运行

定义全局变量

代码

var1 = 123
def func():
    global var1
    var1 = 456
    print(var1)

func()
print(var1)

运行

赞赏作者

如果觉得我的文章对你有用,请随意赞赏