【发布时间】:2021-05-05 06:08:45
【问题描述】:
我有一个在列表中查找子字符串的脚本,但在最后一个循环中它没有正确连接字符串。 结果正确:
IDS00388680 Block Commands
IDS00389632 empty
IDS00389629 Run queue offset
IDS00389628 empty
脚本结果:
['IDS00388680', 'Verification error', 'Block Commands']
['IDS00389632', 'Run queue offset', 'Team LS']
['IDS00389629', 'empty', 'empty']
['IDS00389628', 'empty', 'empty']
“Step3”循环中的错误。 我需要按编号 IDS 组合结果“数据”、“结果周期”*** 有关如何解决此错误的任何想法?
我的脚本:
from itertools import zip_longest
task_list = [('IDS00388680', 'https://jira.domain/browse/30682\r\n\r\nA call to the block command has been registered: IDS0147121164\r\nerror: [Teradata][ODBC Teradata Driver] will be decided in circulation.')
,('IDS00389632', 'https://jira.domain/browse/30752\r\n\r\nOne-time failure, probably due to the procedure freezing for a second, the problem was fixed by restarting.\r\n incident resolved')
,('IDS00389629', 'https://jira.domain/browse/30753\r\n\r\nThe package did not have time to finish work due to launch at the end of the day.\r\nReconfigured the cluster\r\n incident resolved')
,('IDS00389628', 'https://jira.domain/browse/30754\r\n\r\nReduced resources as a result, there were not enough threads to execute.\r\n incident resolved')]
result_cycle = [['IDS00388680', 'Verification error', 'Block Commands'],
['IDS00389629', 'Run queue offset', 'Team LS']]
result = []
#Step3 - concatenate the IDS field in the task_list and the values from the result_cycle
ziplong = zip_longest(task_list, result_cycle, fillvalue='empty')
for i in ziplong:
if i[1] != "empty":
result.append([i[0][0], i[1][1], i[1][2]])
else:
result.append([i[0][0], "empty", "empty"])
for m in result:
print(m)
【问题讨论】:
标签: python-3.x list string-concatenation