我正在尝试进行logtest,我已经输出了,但是我要添加一些内容,但是我做不到
for i in range(int(sys.argv[1]),int(sys.argv[2])):
stdate = parser.parse(sys.argv[3])
todate = parser.parse(sys.argv[4])
while stdate <= todate:
lctr += 1
if lctr == 1:
if fctr % 100 == 0:
print('creating sample' + str(fctr).rjust(5,"0") + '.txt')
f = open("sample" + str(fctr).rjust(5,"0") + '.txt',"w")
f.write(str(i) + ', ' + stdate.strftime('%m/%d/%Y') + ', 0800, A\r\n')
f.write(str(i) + ', ' + stdate.strftime('%m/%d/%Y') + ', 1700, Z\r\n')
stdate = stdate + timedelta(days=1)
if lctr == 180 :
fctr += 1
lctr = 0
f.close()
这是输出
100001, 02/01/2019, 0800, A
100001, 02/01/2019, 1700, Z
100001, 02/02/2019, 0800, A
100001, 02/02/2019, 1700, Z
100001, 02/03/2019, 0800, A
100001, 02/03/2019, 1700, Z
100002, 02/01/2019, 0800, A
100002, 02/01/2019, 1700, Z
100002, 02/02/2019, 0800, A
100002, 02/02/2019, 1700, Z
100002, 02/03/2019, 0800, A
100002, 02/03/2019, 1700, Z
100003, 02/01/2019, 0800, A
100003, 02/01/2019, 1700, Z
100003, 02/02/2019, 0800, A
100003, 02/02/2019, 1700, Z
100003, 02/03/2019, 0800, A
100003, 02/03/2019, 1700, Z
100004, 02/01/2019, 0800, A
100004, 02/01/2019, 1700, Z
100004, 02/02/2019, 0800, A
100004, 02/02/2019, 1700, Z
100004, 02/03/2019, 0800, A
100004, 02/03/2019, 1700, Z
但这是我想要成为的输出
100001, 02/01/2019, 0800, A
100001, 02/01/2019, 1700, Z
100001, 02/02/2019, 0800, A
100001, 02/02/2019, 1700, Z
100001, 02/03/2019, 0800, A
100001, 02/03/2019, 1700, Z
100002, 02/01/2019, 0800, A
100002, 02/01/2019, 1700, Z
100002, 02/02/2019, 0800, A
100002, 02/02/2019, 1700, Z
100002, 02/03/2019, 0800, A
100002, 02/03/2019, 1700, Z
100003, 02/01/2019, 0800, A
100003, 02/01/2019, 1700, Z
100003, 02/02/2019, 0800, A
100003, 02/02/2019, 1700, Z
100003, 02/03/2019, 0800, A
100003, 02/03/2019, 1700, Z
100004, 02/01/2019, 0800, A
100004, 02/01/2019, 1700, Z
100004, 02/02/2019, 0800, A
100004, 02/02/2019, 1700, Z
100004, 02/03/2019, 0800, A
100004, 02/03/2019, 1700, Z
答案 0 :(得分:0)
SIGCONT