
本文共 3720 字,大约阅读时间需要 12 分钟。
���������������������������������������������
������
��������� Python ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������
- ���������������������������������������������������������������������������������������������������������������������
- ������������������������������������������������������������������������������������
- ������������������������������������������������������������������������������������������
������������������
- ������������������������������������������������������
.py
��������������������� - ������������������������������������������������������������������������������������������
- ������������������������������
- ������������������������������������������������������������������
- ������������������������������
������������������
-
���������������������
import my_module # ���������my_module���������������.py������my_module.my_function()
-
���������������������
import my_module as my # ������������������������������������������my.my_function()
-
������������������
from my_module import ( my_function, MyClass)my_function()instance = MyClass()
-
���������������
from my_module import * # ������������������������������
-
������������������������������������
import sysif __name__ == "__main__": sys.meta_path.append autocomplete import binder) # ���������������������Python������������ ...
if __name__ == "__main__"
���������
���������������������������������������������������������������������������������������������������
������������������������������������if __name__ == "__main__"
���������������������������������������������������������������
������������������������������
������������������
������������������Python ������������������������������
os
, sys
������sys.path
������������������������������������
���������������������������������
sys.path
���������������������������������������������������������������sys.path
������������������������������������
import syssys.path.append('../lib') #���������������������sys.path.append('~/.local/share/python') #������������������������
���
������������������������������������������������������������������+������__init__.py
���������������������������������������������������������������������������
���������������
my_package/��������� __init__.py��������� module1.py��������� module2.py��������� submodule/ ��������� __init__.py ��������� submodule_module.py
������������������������������������������������������������������__init__.py
������������������������������
���������������
-
������������������
import my_package
-
������������������������
from my_package import *
������������
���������������������������������������������������������������������������������������������
���������������������
���������������������������������������������������������������������������������������������������������������������������
setName() Student.setName() Dog.setName()
������������������������������������������������������������������������������������������������������
���������������
- ���������������������������������������������������������������������������������
- ������������������������������������������������������������������������
- ���������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
