【发布时间】:2018-01-22 02:47:06
【问题描述】:
我不知道下面的代码有什么问题,抛出一个错误,
UnboundLocalError: local variable 'r' referenced before assignment
请帮帮我
代码:
if i != 0:
agentAttributes = etree.SubElement(root, "agentAttributes")
agentAttribute = etree.SubElement(agentAttributes, "agentAttribute")
attribute = etree.SubElement(agentAttribute, "attribute")
refURL = etree.SubElement(attribute, "refURL")
refURL.text = "/unifiedconfig/config/attribute/5007"
name = etree.SubElement(attribute, "name")
name.text = "CustomerService"
attributeValue = etree.SubElement(agentAttribute, "attributeValue")
attributeValue.text = "5"
datatype = etree.SubElement(attribute, "datatype")
datatype.text = "4"
# print("After adding"+(str(etree.tostring(root))))
r = requests.put(wsurl, verify=False, data=(etree.tostring(root)),
headers={"Content-Type": "application/xml"}, auth=('tsup01', 'Sp33chs0ft'))
# print("after put"+(r.text))
conn.close()
conn1.close()
#print("Adding one Attribute to all agents duration in hh:mm:ss = " + str(datetime.now() - startTime))
#returnString = "Adding one Attribute to all agents duration in hh:mm:ss = " + str(datetime.now() - startTime)
return HttpResponse(r.text)
【问题讨论】:
-
您能提供完整的堆栈跟踪吗?还有为什么你有一个
sails.js标签?谢谢!