只能将 str(不是 "NoneType")连接到 str
can only concatenate str (not "NoneType") to str
获取 api 响应文本并在 python3
中打印时遇到问题
response = session.get(url=url, headers=headers, json=payload, verify=cabundle,
auth=auth)
if response.status_code == 200:
print(response.status_code)
print("Response is:")
data = json.loads(response.text)
print(data)
if data['issues']!= []:
issueId = data['issues'][0]['id']
print("Issue ID : " +issueId)
输出:
200
Response is:
Expecting value: line 3 column 1 (char 4)
can only concatenate str (not "NoneType") to str
谁能帮忙解决这个问题?
连接前检查 issueId
是否存在:
issueId = data['issues'][0]['id']
if issueId:
print("Issue ID : " + issueId)
使用字符串参数,如果是none类型,它会插入None
。
print(f"Issue Id: {issueId}")
获取 api 响应文本并在 python3
中打印时遇到问题response = session.get(url=url, headers=headers, json=payload, verify=cabundle,
auth=auth)
if response.status_code == 200:
print(response.status_code)
print("Response is:")
data = json.loads(response.text)
print(data)
if data['issues']!= []:
issueId = data['issues'][0]['id']
print("Issue ID : " +issueId)
输出:
200
Response is:
Expecting value: line 3 column 1 (char 4)
can only concatenate str (not "NoneType") to str
谁能帮忙解决这个问题?
连接前检查 issueId
是否存在:
issueId = data['issues'][0]['id']
if issueId:
print("Issue ID : " + issueId)
使用字符串参数,如果是none类型,它会插入None
。
print(f"Issue Id: {issueId}")