【发布时间】:2013-07-19 09:09:51
【问题描述】:
我有一个非常简单的问题,关于在用 python 3 编写的脚本中杀死子子进程。
在哪里,
如果有的话
my_process = None
def open_storage():
my_process = subprocess.Popen("waffles.exe")
def kill_children():
my_process.kill()
调用open_storage()后,如果我调用kill_children(),我得到
AttributeError: 'NoneType' object has no attribute 'kill'
如果我有,
my_process = 无
my_process = subprocess.Popen("waffles.exe")
def kill_children():
my_process.kill()
一切正常。
谁能解释这种奇怪的行为?我需要将open_storage() 作为一个函数,因为它被设计为由 tkinter 按钮触发。
谢谢。
【问题讨论】:
标签: python windows web-services file web-applications