我有一个非常简单的问题,关于在用 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 按钮触发。
谢谢。