1. 程式人生 > >python導入模塊(2)

python導入模塊(2)

line -h .com pre () main alt class print

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)