Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80760
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'matches': 0.07; "subject:' ": 0.07; 'filename': 0.09; 'subject: <': 0.09; 'subject:position': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '23,': 0.16; 'codec': 0.16; 'filename)': 0.16; 'pathname': 0.16; 'subject: \n ': 0.16; 'subject:>': 0.16; 'wrote:': 0.18; 'help.': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'fri,': 0.33; "can't": 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'there': 0.35; '14,': 0.36; 'raising': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'error.': 0.37; 'skip:o 20': 0.38; 'nov': 0.38; 'fact': 0.38; 'recent': 0.39; 'subject:can': 0.39; 'called': 0.40; 'url:mail': 0.40; 'skip:u 10': 0.60; 'skip:c 50': 0.60; 'kindly': 0.61; 'literature': 0.84; 'joel': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=biBuDVPaB1iVSyeH6tf2Lp4BzvUtWzDuttJ5VztcUlI=; b=ZnsUD9dRTycPyGaMf0Sdj0sUcFyv5m/Glhf1VyvkXfUu+QLyeIjRl1UkAbs827rhr3 j2+ckzArJGsuRAfVGGYeASmJG+HVck0+ggRG1l1uydSzM31/KoxXqv00hfgskgvEOK/i J9M64rIhk7bBtiTvWZMZ5mUJz7yVaYsf8Q+4QMzkLVz86/DbG6Y75JR5R+8dyFB4XBWU o3JnTHjb5UYU+1pW+9ety4LFtAlaYt0IPr7dRoCHg9TaS7woFKduuQjIAE/Dyfym8VHZ jL+rZfZI7M94tEaIavl1NQDFdB5V4ZGFr/nlrRQ24UuIRon6/8afYrwLAs1nOKDTFFNN 3GSw== |
| MIME-Version | 1.0 |
| X-Received | by 10.140.49.107 with SMTP id p98mr10896149qga.20.1415968201643; Fri, 14 Nov 2014 04:30:01 -0800 (PST) |
| In-Reply-To | <0a5917ca-70f3-4297-9e98-e8ed0556ee22@googlegroups.com> |
| References | <0a5917ca-70f3-4297-9e98-e8ed0556ee22@googlegroups.com> |
| Date | Fri, 14 Nov 2014 07:30:01 -0500 |
| Subject | Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to <undefined> |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15818.1415968687.18130.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415968687 news.xs4all.nl 2900 [2001:888:2000:d::a6]:53277 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:80760 |
Show key headers only | View raw
On Fri, Nov 14, 2014 at 6:57 AM, <satishmlmlml@gmail.com> wrote:
> 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>
You should understand encodings. There is lots of literature on the
web about unicode and python. In your case, the fact that you are
reading a file called cp1252.py and your code is raising a
UnicodeDecodeError should be a clue
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to <undefined> satishmlmlml@gmail.com - 2014-11-14 03:57 -0800 Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to <undefined> Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-14 07:30 -0500
csiph-web