码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-03-27 21:05:49      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:nbsp   world   class   function   import   from   cmd   hello   print   

在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下调用

技术分享

 

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

标签:nbsp   world   class   function   import   from   cmd   hello   print   

原文地址:http://www.cnblogs.com/xuqiulin/p/6628727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!