Seite 1 von 1

urlparse

Verfasst: Montag 29. September 2008, 20:13
von nemomuk
Hallo,

ich verzweifle gerade...

Code: Alles auswählen

import urlparse
parsed_url = urlparse.urlsplit(url)
print parsed_url.netloc
Error:

Code: Alles auswählen

[Mon Sep 29 21:08:07 2008] [error] [client IP] PythonHandler mod_python.cgihandler: Traceback (most recent call last):
[Mon Sep 29 21:08:07 2008] [error] [client IP] PythonHandler mod_python.cgihandler:   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch\n    result = object(req)
[Mon Sep 29 21:08:07 2008] [error] [client IP] PythonHandler mod_python.cgihandler:   File "/usr/lib/python2.4/site-packages/mod_python/cgihandler.py", line 96, in handler\n    imp.load_module(module_name, fd, path, desc)
[Mon Sep 29 21:08:07 2008] [error] [client IP] PythonHandler mod_python.cgihandler:   File "/var/www/vhosts/aaa/index.py", line 24, in ?\n    print parsed_url.netloc
[Mon Sep 29 21:08:07 2008] [error] [client IP] PythonHandler mod_python.cgihandler: AttributeError: 'tuple' object has no attribute 'netloc'
Ich verstehe nicht warum das nicht geht... Ich rufe die Daten aus einer Datenbank ab. Python Version: 2.4, OS-Linux-Debian.

Danke
MfG

Verfasst: Montag 29. September 2008, 20:17
von Trundle
Dokumentation hat geschrieben:The return value is actually an instance of a subclass of tuple. This class has the following additional read-only convenience attributes:
[...]
Changed in version 2.5: Added attributes to return value.
Und in Python2.4 ist das halt schlichtweg noch ein Tupel.

Verfasst: Montag 29. September 2008, 20:18
von nemomuk
ah, danke...