?? ??
1. Import
Python ??? ??? ?? ????? ??? ?????. ??? ????? ???? ?? ??? ???? ???. ??? ????? import ???? ?????.
import? ??? ????? ??? ????.
import module1[, module2[,... moduleN]
?? ?? ?? ????? ???? math ??? ?????. ?????? import ?? ???? ??? ?? ?? ??? ??? ??? ?????.
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import math _author_ = '兩點(diǎn)水' print(math.pi) 輸出的結(jié)果: 3.141592653589793
??? ????? ? ? ???? ???? ? ?? ?????. ??? ?? ??? ??? ???? ???? ?? ??? ? ????.
import ?? ??? ? Python ?????? ?? ??? ??? ????
???? Python? ?? ??? ?????. ?? ??? ??? ???? ???? ?????. Python ?????? ??? ?????? ??? ??? ??? ????. ?? ?? ??? ?? ??? ???? ???? ?? ??? ???? ?? ??? ??? ?? ????. ?? ??? Python? ?????? ??? ? ???? ? ?????? ??? ?? ???? ???. ?? ??? sys ??? path ??? ?????.
??? ??? ??? ? ????:
#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys print(sys.path)
?? ??:
['C:\Users\Administrator\Desktop\Python\Python8Code', 'G:\PyCharm 2017.1.4\helpers\pycharm', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python36.zip', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36\DLLs', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages', 'C:\Users\Administrator\Desktop\Python\Python8Code\com\Learn\module\sys']
2.from···import
???? ??? ???? ?? ???? ??? ?? ??? ? ?? ????
Python??? import ???? ???? ??? ?????. ???? ??? ???? ??? ?? ???? ???? ???? ???? ?? ???? ???. ??? ??, ? ??? ???? ?? import?? ??? from···import ?? ???? ???.
??? ??? ????.
from modname import name1[, name2[, ... nameN]]
??? ?? ? from···import ???? import ???? ???? ???? ????? ????.
???? ?? ??? ?? ? ?? ?? ?????.
import? sys ??? ??? ?? ?? ??? ?????.
from···import? ?? ??? ?? ?????.
3. from ·· · import *
?? ??? ?? sys ???? ???? ?? ??? ?? ??? ? ??? ? ? ????. ??? ?? ??? ???? ??? ??? ?? ???? ?? ?? sys ???? ?? ??? ???? ?? sys import ?? ???? ? ??? ? ???? ???? ? ?? ???? ? ?? ? ?? ????? ?? ??? ?? ????
??, from ··· import * ?? ?????. ? ?? ??? ?? ??? ??? ??? ? ????. ?:
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- from sys import * print(version) print(executable)
??? ??? ????.
3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe
??: ?? ??? ?? ??? ??? ???? ?? ??? ?????. ??? ? ??? ????? ? ???.