tempfile
Verfasst: Freitag 29. April 2005, 13:08
hallo allerseits,
ich spiele zur zeit ein wenig mit dem tempfile modul.
beim ausführen des obigen codes erscheint folgender fehler:
ich frage mich was ich falsch mache.
Edit (Leonidas): Code in Python Tags gesetzt.
Code: Alles auswählen
import os, tempfile as _tempfile
base_image = _tempfile.mktemp() + '.jpg'
change_image = '/root/tmp/energis.jpg'
print base_image
tmp = open('Djavo.jpg', 'r')
dat = tmp.read()
tmp.close()
tempfile = open(base_image, 'wb')
tempfile.write(dat)
tempfile.close()
new_image = _tempfile.mktemp() + '.jpg'
print base_image
print "\n"
print new_image
#os.system()
tempfile = open(new_image, 'r')
data = tempfile.read()
tempfile.close()
print data
beim ausführen des obigen codes erscheint folgender fehler:
Code: Alles auswählen
/tmp/tmp3GCYEV.jpg
/tmp/tmp3GCYEV.jpg
/tmp/tmpQcU2Fh.jpg
Traceback (most recent call last):
File "tmp.py", line 22, in ?
tempfile = open(new_image, 'r')
IOError: [Errno 2] No such file or directory: '/tmp/tmpQcU2Fh.jpg'
Edit (Leonidas): Code in Python Tags gesetzt.