import sys
print
(sys.path)
""" ['c:\\users\\song\\pycharmprojects\\宋建國工具包\\python高階\\私有化',
'c:\\users\\song\\pycharmprojects\\宋建國工具包',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_display',
'd:\\software\\anaconda\\python37.zip',
'd:\\software\\anaconda\\dlls',
'd:\\software\\anaconda\\lib',
'd:\\software\\anaconda',
'd:\\software\\anaconda\\lib\\site-packages',
'd:\\software\\anaconda\\lib\\site-packages\\win32',
'd:\\software\\anaconda\\lib\\site-packages\\win32\\lib',
'd:\\software\\anaconda\\lib\\site-packages\\pythonwin',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_matplotlib_backend']
"""
import sys
print
(sys.path)
""" ['c:\\users\\song\\pycharmprojects\\宋建國工具包\\python高階\\私有化',
'c:\\users\\song\\pycharmprojects\\宋建國工具包',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_display',
'd:\\software\\anaconda\\python37.zip',
'd:\\software\\anaconda\\dlls',
'd:\\software\\anaconda\\lib',
'd:\\software\\anaconda',
'd:\\software\\anaconda\\lib\\site-packages',
'd:\\software\\anaconda\\lib\\site-packages\\win32',
'd:\\software\\anaconda\\lib\\site-packages\\win32\\lib',
'd:\\software\\anaconda\\lib\\site-packages\\pythonwin',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_matplotlib_backend']
"""sys.path.insert(0,
"")print
(sys.path)
""" ['',
'c:\\users\\song\\pycharmprojects\\宋建國工具包\\python高階\\私有化',
'c:\\users\\song\\pycharmprojects\\宋建國工具包',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_display',
'd:\\software\\anaconda\\python37.zip',
'd:\\software\\anaconda\\dlls',
'd:\\software\\anaconda\\lib',
'd:\\software\\anaconda',
'd:\\software\\anaconda\\lib\\site-packages',
'd:\\software\\anaconda\\lib\\site-packages\\win32',
'd:\\software\\anaconda\\lib\\site-packages\\win32\\lib',
'd:\\software\\anaconda\\lib\\site-packages\\pythonwin',
'd:\\software\\pycharm\\pycharm 2019.1.3\\helpers\\pycharm_matplotlib_backend']
"""
python新增包路徑 python包相對匯入
絕對路徑匯入格式為import a.b或者from a import b,相對路徑匯入格式為from import b或者from a import b。python2預設為相對路徑匯入,python3預設為絕對路徑匯入。為使python2,3通用,建議採用相對路徑匯入from a import b...
Python 高階 模組 包
命名空間和變數作用域的比較 變數名的查詢覆蓋 匯入模組 模組匯入的特性 模組內建函式 package 包 預設的模組搜尋路徑在 python 解析器編譯安裝時被指定,我們可以通過 sys 模組來檢視和修改它 in 4 sys.path out 4 usr bin usr lib python2.7 ...
python包 模組路徑
當python執行import語句時,它會在一些路徑中搜尋python模組和擴充套件模組。可以通過sys.path檢視這些路徑,比如 import sys sys.path usr lib python2.7 site packages demo nova hooks 5 py2.7.egg usr...