python 定义函数 两个文件调用函数


在def_function.py文件里面写

#coding=utf-8

#定义函数
def hello():
    print "hello world"

  

在test.py里面调用

#coding=utf-8

from def_function import hello
#from def_function import * #导入该文件里的所有函数

#调用函数
hello()

  

在cmd下调用

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM