Python 模块

作者: ferrint | 来源:发表于2017-03-14 20:24 被阅读0次

关键词:模块

模块就是一个保存了Python代码的文件。模块能定义函数,类和变量。模块里也能包含可执行的代码(类比node.js模块)

语法:import module1[, module2[,... moduleN]

# support.py
def print_func( par ):
   print "Hello : ", par
   return

引入

# 导入模块
import support
# 现在可以调用模块里包含的函数了
support.print_func("Zara")

# Hello : Zara

相关文章

网友评论

    本文标题:Python 模块

    本文链接:https://www.haomeiwen.com/subject/fjfknttx.html