如何使用python3的多处理池运行两个不同的函数?

2024-09-30 01:20:45 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,假设我有这个代码:

import time

def helloworld(sleep_time):
    while True:
        time.sleep(sleep_time)
        print('Hello world!')

def hellocountry():
    while True:
        time.sleep(60)
        print('Hello country!')

if __name__ == '__main__':
    with Pool(3) as p:
        p.map(helloworld, [1, 5, 7])

当地狱世界被处决的时候,我该如何处死希腊国?我想我可以写一个包装器函数,但这看起来相当笨拙和不和谐。在


Tags: 代码nameimporttruehelloworldiftime

热门问题