[d]如何在python中调用python文件

[d]怎么在python中调用python文件
我说的调用不是第一个调第二个的函数,而是调文件,
不是这个
#######################################
#文件1内容:

#FileName: test.py
def work():
  print "Hello,world!"
文件保存为test.py
----------------------
#文件2内容:
#FileName: main.py
import test #将文件1 test.py导入进来
test.work() #调用test.py中定义的work()函数
----------------------
###############################################
而是
#############################
#文件1内容:
#FileName: test.py
print 'hello'
----------------------
#文件2内容:
#FileName: main.py
……#调用文件1----------------------
--------------------
Double行动:
原帖分数:30
帖子加分:30
 

------解决方案--------------------
探讨

不用打开文件,直接给文件地址就行,用execfile()函数

execfile(filename[, globals[, locals]])

This function is similar to the exec statement, but parses a file instead of a string. It is different from the impor……