Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在后台运行python_Python_Linux - Fatal编程技术网

在后台运行python

在后台运行python,python,linux,Python,Linux,我一直在寻找这个问题,但没有找到任何有价值的答案 我想制作一个脚本(假设它是一个库),在重新启动时运行一些函数。在我的库中,将有一个函数 def randomfunction(): print("randomtext") 加载此函数后,每次在任何python运行中调用randomfunction()时(我将.py作为cgi脚本),都会返回“randomtext” 这是可能的还是我错过了什么 如果我使用exec,它在pythonidle上工作,但我希望这个exec在系统上。这将适用于l

我一直在寻找这个问题,但没有找到任何有价值的答案

我想制作一个脚本(假设它是一个库),在重新启动时运行一些函数。在我的库中,将有一个函数

def randomfunction():
    print("randomtext")
加载此函数后,每次在任何python运行中调用randomfunction()时(我将.py作为cgi脚本),都会返回“randomtext”

这是可能的还是我错过了什么



如果我使用exec,它在pythonidle上工作,但我希望这个exec在系统上。这将适用于linux操作系统。

您不需要某种进程间通信吗

可能值得一看这些文档:

而且, 也许对你有帮助。我认为它提供了一个解决方案,你正在寻找