UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in
MOS37F MOS37F
mos37f at gmail.com
Wed Oct 15 23:16:13 EDT 2008
import shelve
from ShelfFile import ABC
from zipfile import ZipFile, ZIP_DEFLATED
ShelfFilePath = 'E:\DIR\DIR\DIR\ShelfFile'
def TEST():
ShelfFileObject = shelve.open(ShelfFilePath)
RetrievedObject = ShelfFileObject['abc']
ShelfFileObject.close()
return RetrievedObject
RetrievedObject = TEST()
FilePath1 = RetrievedObject.DirectoryPath1 + '\\' + 'Filename.txt'
FilePath2 = RetrievedObject.DirectoryPath2 + '\\' + 'Filename.zip'
#Would expect True -> UV.DirectoryPath1 == 'E:\TestDir\TestDir'
if UV.DirectoryPath1 == 'E:\TestDir\TestDir': print 'UV.DirectoryPath1 ==
E:\TestDir\TestDir:'
# Try First without setting UV.DirectoryPath1
#UV.DirectoryPath1 = 'E:\TestDir\TestDir'
FIL = ZipFile(FilePath2, "w", ZIP_DEFLATED)
FIL.write(FilePath1)
FIL.close()
print '\tComplete:', FilePath2
####################################################
Debug I/O: #Yes, just as expected
UV.DirectoryPath1 == E:\TestDir\TestDir:
Exceptions: #Not as expected
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 10:
ordinal not in range(128)
File "File Path", line '#', in <module>
FIL.write(FilePath1)
File "C:\Python25\Lib\zipfile.py, line 568, in write
self.fp.write(zinfo.FileHeader())
File "C:\Python25\Lib\zipfile.py, line 260, in FileHeader
return header + self.filename + extra
####################################################
Uncomment: #UV.DirectoryPath1 = 'E:\TestDir\TestDir'
Debug I/O: #Yes, just as expected
UV.DirectoryPath1 == E:\TestDir\TestDir:
Exceptions: #Yes, just as expected - BUT WHY THE DIFFERENCE? -> '\\' ?????
E:\TestDir\TestDir\Filename.zip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081015/4dbcdf2c/attachment.html>
More information about the Python-list
mailing list