首页 > 代码库 > python导入模块(2)

python导入模块(2)

 

main.py文件

#_*_coding:utf-8_*_
#__author__ = "csy"

from module_csy import say_hello as hello   #module_csy模块的say_hello函数起别名为hello

print(hello())

module_csy.py文件

#_*_coding:utf-8_*_
#__author__ = "csy"

name = csy
def say_hello():
    print(Hello csy!)
执行main.py输出结果:

技术分享

 

python导入模块(2)