Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Entropyobserver
Python24
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Python24
/
00Python
/
day07
/
basic02.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
49 lines (44 loc) · 1.55 KB
master
Breadcrumbs
Python24
/
00Python
/
day07
/
basic02.py
Copy path
Top
File metadata and controls
Code
Blame
49 lines (44 loc) · 1.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
函数中的局部变量的释放狮是在函数执行完后就马上消失
全局变量是等真个程序运行完后进行销毁,作用域是整个函数
1- 如果局部变量名和全局的相同,那么执行的时候根据就近原则
2- 如果函数内找不到该变量名,那么就去找全局变量
3- 如果函数内想要就该外面的全局变量,使用globe关键字
"""
num
=
10
def
my_func01
():
# num = 20 这里是创建一个新的内部变量
global
num
num
=
20
# 这里告诉函数并非创建新的局部变量,而是使用全局的变量操作
print
(
"内部num = %s"
%
num
)
my_func01
()
print
(
"外部num = %s"
%
num
)
"""
函数自建函数文档说明help(len)
如果函数内没有自定义文档说明,那么就返回找函数名上面一行的注释
"""
help
(
len
)
# 这里是没有专门的说明进行返回的内容
def
my_func02
(
num01
,
num02
):
"""
返回两个参数的和
:param num01: 数字1
:param num02: 数字2
:return: 两个数字的和
"""
return
num01
+
num02
help
(
my_func02
)
"""
id(obj)查找obj内存的物理地址引用门牌号
类似:定了一个房间但是没有入住,调用的时候才入住
a,b指向同一个房间,节省内存
"""
a
=
1000
b
=
1000
c
=
"abc"
# 字符串,元祖()等不可不的数据类型,修改的话是copy重新开一个房间
d
=
"abc"
# 列表[],字典可变数据结构,修改的话是在同一个房间进行修改的。
c
=
"abcd"
print
(
id
(
a
))
print
(
id
(
b
))
print
(
id
(
c
))
print
(
id
(
d
))
You can’t perform that action at this time.