我的python脚本中有下面的代码,我用它来获取JIRA问题的component字段的值,不管component/s字段有什么值,下面的逻辑是读取这些值,如果值与R Ciapara或CTX匹配,那么它将执行下一个任务,基本上删除文本部分,只获取数值从下面1.3和1.2英寸的弦开始案子。之后如果两个值相同,例如R Ciapara 1.3(已发布),R Ciapara 1.3,我将使其唯一。在这种情况下,它将给我1.3,1.3,那么我将使其为4.3
组件字段的示例为
Component/s: M Nx, M CitLx, R Ciapara 1.3 (Released), CTX 1.2
python脚本中的逻辑:
def Test(Host, issue):
allModules = []
componentmatch = 0
for version in issue["fields"]["components"]:
cacheData = json.dumps(version)
jsonToPython = json.loads(cacheData)
print jsonToPython
#componentmatch = 0
if jsonToPython['name'][:10] == "R Ciapara " or version["name"][:4] == "CTX ":
componentmatch += 1
componentmatch = re.findall(r"\d+\.\d+", jsonToPython['name'])
if componentmatch:
allModules.append(componentmatch[0])
d={i for i in allModules}
p=list(d)
matchcomp = ("[{}]".format(", ".join(p)))
return matchcomp
“int”对象不可iterable下面出现错误:
Processing TPT-3
R Ciapara 4.3 (Released)
Ciapara 1.4.90.0
{u'self': u'https://test/rest/api/2/component/730', u'id': u'730', u'name': u'M Nx'}
{u'self': u'https://test/rest/api/2/component/73', u'id': u'73', u'name': u'M CitLx'}
{u'self': u'https://test/rest/api/2/component/1', u'id': u'1', u'name': u'R Ciapara 1.3 (Released)'}
[1.3]
[1.4, 1.2]
Processing TPT-2
R Ciapara 1.3(U1)
Ciapara 1.4.3.4
{u'self': u'https://test/rest/api/2/component/7', u'id': u'7', u'name': u'R Ciapara 1.3(U1)'}
[1.3]
[1.4]
Processing TPT-1
R Ciapara 1.4
Ciapara 1.4.73.4
{u'self': u'https://test/rest/api/2/component/733', u'id': u'733', u'name': u'R Ciapara 1.4'}
{u'self': u'https://test/rest/api/2/component/7335', u'id': u'7335', u'name': u'R Ciapara 1.4(U1)'}
Traceback (most recent call last):
TypeError: 'int' object is not iterable
无法理解我在这里错过了什么?你知道吗
您正在将
1
添加到componentmatch
此处:然后将
componentmatch
重新分配给re.findall()
的返回输出,它在这里返回字符串列表:然后再次输入
if
语句:现在您正试图再次将
1
添加到字符串列表中,这将引发以下错误:您正试图向字符串列表中添加整数。你知道吗
现在,我改变了我的逻辑,它的工作
相关问题 更多 >
编程相关推荐