Python3 基础语法
-
在 python 用
import
或者from...import
来导入相应的模块。 -
将整个模块(
somemodule
)导入,格式为:import somemodule
-
从某个模块中导入某个函数,格式为:
from somemodule import somefunction
-
从某个模块中导入多个函数,格式为:
from somemodule import firstfunc, secondfunc, thirdfunc
-
将某个模块中的全部函数导入,格式为:
from somemodule import *
import sys
print('================Python import mode==========================')
print('python 版本为', sys.version)
#导入特定的成员
from sys import version
print('================python from import===================================')
# version,所以此处引用时不需要加sys.version
print('python 版本为', version)