Ok, meine dritte Frage heute ist , wie schaut ein Dateiupload in python eigentlich aus?
req=Request(formpath,filepath,header)
urlopen(req)
klappt bei mir nicht...
Dateiupload mit Python
Bei mir auch nicht:
Worüber reden wir hier denn eigentlich? CGI? WSGI? Ein Webframework?
Code: Alles auswählen
In [90]: req = Request(formpath, filepath, header)
---------------------------------------------------------------------------
<type 'exceptions.NameError'> Traceback (most recent call last)
/home/bj/<ipython console> in <module>()
<type 'exceptions.NameError'>: name 'Request' is not defined
- veers
- User
- Beiträge: 1219
- Registriert: Mittwoch 28. Februar 2007, 20:01
- Wohnort: Zürich (CH)
- Kontaktdaten:
Du hast vergessen das Import-Statement hin zu schreibenpythonguy hat geschrieben:Um mit Hilfe eines Python Scripts automatisiert Bilder upzuloaden, du hast allerdings vergessen, urllib zu importieren...
[url=http://29a.ch/]My Website - 29a.ch[/url]
"If privacy is outlawed, only outlaws will have privacy." - Phil Zimmermann
"If privacy is outlawed, only outlaws will have privacy." - Phil Zimmermann
Ok, jetzt aberveers hat geschrieben:Du hast vergessen das Import-Statement hin zu schreibenpythonguy hat geschrieben:Um mit Hilfe eines Python Scripts automatisiert Bilder upzuloaden, du hast allerdings vergessen, urllib zu importieren...
Code: Alles auswählen
from urllib import *
from urllib2 import *
formpath="http://www.domain.de/formular"
filepath="f:\\images\\pic.jpeg"
header={'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
req=Request(formpath,filepath,header)
urlopen(req)