0
간단한 Python 통화를 테스트하는 데 문제가 있습니다 테스트를 실행하면 항상이 오류가 발생합니다 코드에서 아마도 null 객체에 액세스하고 있습니다. 하지만 어디 어떤 아이디어? 고맙습니다 !WebPy 'NoneType'객체에 '__getitem__'속성이 없습니다.
#!/usr/bin/env python
import web
import xml.etree.ElementTree as ET
tree = ET.parse('user.xml')
root = tree.getroot()
urls = (
'/users', 'list_users',
'/users/(.*)', 'get_user'
)
app = web.application(urls, globals())
class list_users:
def GET(self):
output = 'users:[';
for child in root:
print 'child', child.tag, child.attrib
output += str(child.attrib) + ','
output += ']';
return output
class get_user:
def GET(self, user):
for child in root:
if child.attrib['id'] == user:
return str(child.attrib)
if __name__ == '__main__':
app.run()
** 전체 ** 추적을 제공해야합니다. –