我知道这不是您问题的实际解决方案,我只会添加评论,但它太长了,所以我将发布作为答案。
我无法复制您的问题,但通过查看 shareplum.py 的源代码,您可以了解程序抛出错误的原因。在 shareplum.py 的第 196 行中,有 if 子句 (if response.status_code == 200:) 检查访问您的共享点 url 的请求是否成功(比它的状态码 200)以及请求是否失败(比它有一些其他状态码)它抛出异常(无法获取用户信息列表)。如果您想了解有关您的问题的更多信息,请转到您的 shareplum.py 文件(“C:\Users\me\AppData\Local\Programs\Python\Python36\lib\site-packages\shareplum\shareplum.py”)和在第 207 行之前添加此行 print('{} {} Error: {} for url: {}'.format(response.status_code, 'Client'*(400 <= response.status_code < 500) + 'Server'*(500 <= response.status_code < 600), response.reason, response.url)) ('raise Exception("Can't get User Info List")')。那么你的 shareplum.py 应该是这样的:
# Parse Response
if response.status_code == 200:
envelope = etree.fromstring(response.text.encode('utf-8'))
listitems = envelope[0][0][0][0][0]
data = []
for row in listitems:
# Strip the 'ows_' from the beginning with key[4:]
data.append({key[4:]: value for (key, value) in row.items() if key[4:]})
return {'py': {i['ImnName']: i['ID']+';#'+i['ImnName'] for i in data},
'sp': {i['ID']+';#'+i['ImnName'] : i['ImnName'] for i in data}}
else:
print('{} {} Error: {} for url: {}'.format(response.status_code, 'Client'*(400 <= response.status_code < 500) + 'Server'*(500 <= response.status_code < 600), response.reason, response.url))
raise Exception("Can't get User Info List")
现在再次运行您的程序,它应该会打印出它为什么不工作的原因。
我知道最好不要更改 Python 模块中的文件,但如果你知道你更改了什么,那么就没有问题,所以当你完成后,只需删除添加的行。
此外,当您找到状态码时,您可以在线搜索,只需在 google 中输入或在 List_of_HTTP_status_codes 上搜索即可。