如何在Python 3中仅对内部和While循环一次执行一次代码块

时间:2019-01-13 06:12:10

标签: python-3.x

我正在尝试如下创建循环:

我不知道该怎么做,最终我的循环将为每个the_num和while循环执行准备和执行

worker.py
def preparation(the_num):
    public datafram_e
    print ('This is preparation ' + str(the_num))
def execution(the_num):
    public datafram_e
    print ('This is execution ' + str(the_num)) 
def protocol(the_num):
    preparation(the_num)
    execution(the_num)  

manager.py
from worker import protocol
if__name__ == "__main__":
    while True:  
        numbers = 'Uno', 'Dos', 'Tres'
        for the_num in numbers:
           protocol(the_num)

我想要的是在循环开始时每次只执行一次def准备(the_num)。

输出:

This is preparation Unos
This is execution Unos
This is preparation Dos
This is execution Dos 
This is preparation Tres
This is execution Tres
This is execution Unos
This is execution Dos 
This is execution Tres
This is execution Unos

以此类推。...

在此先感谢您提供的任何信息

0 个答案:

没有答案