您确实需要更具体。为什么这些需要在线程中?您应该向我们展示您尝试过的内容,或者更详细地描述您想要完成的内容。
在当前设置中,您将线程放入循环中,因此它不能独立于每个用户输入而运行。
编辑:这里是一些整理代码,以您的帖子编辑和评论为基础。
import threadingimport timeimport sysdef background(): while True: time.sleep(3) print 'disarm me by typing disarm'def other_function(): print 'You disarmed me! Dying now.'# now threading1 runs regardless of user inputthreading1 = threading.Thread(target=background)threading1.daemon = Truethreading1.start()while True: if raw_input() == 'disarm': other_function() sys.exit() else: print 'not disarmed'



