我正在尝试写一个脚本,其中列出了3个变量
首先,请参见我当前的脚本:
import datetime as dt
import pandas as pd
x = ['jhon doe', 'GX']
y = ['donald ted', 'GY']
Z = ['smith joe', 'GZ']
start_date = dt.datetime(2019, 4,12)
end_date = dt.datetime(2019, 4,21)
daterange = pd.date_range(start_date, end_date)
for date in daterange:
print(date)
我为这样的输出感到困扰:
12/04/2019, jhone doe, GX
13/04/2019, donald ted, GY
14/04/2019, smith jhoe, GZ
15/04/2019, jhone doe, GX
16/04/2019, donald ted, GY
17/04/2019, smith jhoe, GZ
18/04/2019, jhone doe, GX
19/04/2019, donald ted, GY
14/04/2019, smith jhoe, GZ
21/04/2019, jhone doe, GX
很明显,如果你看到我的预期输出
谁能告诉我怎么做?上面给出了3个变量
我认为没有必要写太多关于这方面的东西
我将使用模函数按周期(x,y,Z)打印它
结果:
看起来工具箱中缺少一个工具:
from itertools import cycle
cycle
允许您创建一个迭代器,它可以连续遍历列表。如果你点击列表的末尾,它将返回到开始输出:
相关问题 更多 >
编程相关推荐