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
Events
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 }}
Ceeson
python3
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
python3
/
Python 7 模块.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
46 lines (30 loc) · 1.35 KB
master
Breadcrumbs
python3
/
Python 7 模块.py
Copy path
Top
File metadata and controls
Code
Blame
46 lines (30 loc) · 1.35 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
import
hello
hello
.
test
()
#类似__xxx__这样的变量是特殊变量,可以被直接引用,
#但是有特殊用途,比如上面的__author__,__name__就是特殊变量,
#hello模块定义的文档注释也可以用特殊变量__doc__访问,
#我们自己的变量一般不要用这种变量名
#_xxx和__xxx这样的函数或变量就是非公开的(private),不应该被直接引用
def
_private_1
(
name
):
return
"Hello, %s"
%
name
def
_private_2
(
name
):
return
"Hi, %s"
%
name
def
greeting
(
name
):
if
len
(
name
)
>
2
:
return
_private_1
(
name
)
else
:
return
_private_2
(
name
)
print
(
greeting
(
"Quu"
))
print
(
greeting
(
"UU"
))
#在Python中,安装第三方模块,是通过包管理工具pip完成的
#如果你正在使用Windows,请参考安装Python一节的内容,
#确保安装时勾选了pip和Add python.exe to Path。
#第三方库都会在Python官方的pypi.python.org网站注册
#pip install Pillow
#默认情况下,Python解释器会搜索当前目录、
#所有已安装的内置模块和第三方模块,搜索路径存放在sys模块的path变量
import
sys
print
(
sys
.
path
)
#如果我们要添加自己的搜索目录,有两种方法
#sys.path.append('/Users/michael/my_py_scripts')
#第二种方法是设置环境变量PYTHONPATH,该环境变量的内容会被自动添加到模块搜索路径中
You can’t perform that action at this time.