我想运行一个用StringIO完成的内存文件。有没有可能做这件事?如下所示:
import StringIO
memfile = StringIO.StringIO()
memfile.write("print 'hello world'")
#with diskfiles I would do:
#os.system('python memfile') ?
#subprocess.Popen('memfile', shell=True)
memfile.close()发布于 2013-06-05 23:18:36
这应该是可行的:
eval(memfile.open().read())编辑:
事实证明exec是必需的,因为eval只接受表达式:
exec memfilehttps://stackoverflow.com/questions/16943596
复制相似问题