UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to <undefined>

satishmlmlml at gmail.com satishmlmlml at gmail.com
Fri Nov 14 12:57:24 CET 2014


For 'mimetypes' in the code given below, python is giving the following error. Kindly help.

>>> import os
>>> matches = []
>>> for (dirname, dirshere, fileshere) in os.walk(r'C:\Python34'):
	for filename in fileshere:
		if filename.endswith('.py'):
			pathname = os.path.join(dirname, filename)
			if 'mimetypes' in open(pathname).read():
				matches.append(pathname)

				
Traceback (most recent call last):
  File "<pyshell#165>", line 5, in <module>
    if 'mimetypes' in open(pathname).read():
  File "C:\Python34\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to <undefined>



More information about the Python-list mailing list