python已經成為程式語言排行榜的老大了,要向不被時代淘汰,就要緊跟時代步伐,在IT編程世界的今天,不會python可是不行的,今天繼續學習python的命令及相關模塊導入學習。
import 與 from...import
在 python 用 import 或者 from...import 來導入相應的模塊。
將整個模塊(somemodule)導入,格式為: import somemodule
從某個模塊中導入某個函數,格式為: from somemodule import somefunction
從某個模塊中導入多個函數,格式為: from somemodule import firstfunc, secondfunc, thirdfunc
將某個模塊中的全部函數導入,格式為: from somemodule import *
示例:
importsys
print('================Python import +\mode==========================');
print('命令行參數為:')
foriinsys.argv:
print(i)
print('\n python 路徑為',sys.path)
命令行參數
很多程序可以執行一些操作來查看一些基本信息,Python可以使用-h參數查看各參數幫助信息:
$ python -h
usage: python [option]...[-c cmd |-m mod | file |-][arg]...
Optionsand arguments (and corresponding environment variables):
-c cmd : program passed inasstring(terminates option list)
-d : debug output from parser (also PYTHONDEBUG=x)
-E : ignore environment variables (such as PYTHONPATH)
-h :printthis help message andexit
[ etc.]