服务器返回结果如下:
<Result>
<accessToken></accessToken>
<appId></appId>
<createTime>0</createTime>
<errorCode>1001</errorCode>
<errorMsg>请重新进入</errorMsg>
<imgUrl></imgUrl>
</Result>
需要提取 imgUrl 中的值,这里的值有时为空,有时是有数据的。
现在用的 re 模块
matches = re.findall('(?:<imgUrl>)(.+)(?:</imgUrl>)',response.text)
这里出现了一个问题:
print(matches)
[]
为啥有大括号,我不需要这个大括号啊,我需要的是纯字符串定义为 matches 变量。如果为空变量也为空。
<Result>
<accessToken></accessToken>
<appId></appId>
<createTime>0</createTime>
<errorCode>1001</errorCode>
<errorMsg>请重新进入</errorMsg>
<imgUrl></imgUrl>
</Result>
需要提取 imgUrl 中的值,这里的值有时为空,有时是有数据的。
现在用的 re 模块
matches = re.findall('(?:<imgUrl>)(.+)(?:</imgUrl>)',response.text)
这里出现了一个问题:
print(matches)
[]
为啥有大括号,我不需要这个大括号啊,我需要的是纯字符串定义为 matches 变量。如果为空变量也为空。