Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90193
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'that?': 0.05; 'error:': 0.07; "subject:' ": 0.07; 'string': 0.09; '"r"': 0.09; '(unicode': 0.09; 'escape': 0.09; 'exit': 0.09; 'shutil': 0.09; 'subject:position': 0.09; 'truncated': 0.09; 'variable,': 0.09; 'afterwards': 0.16; 'backslash': 0.16; 'backslashes': 0.16; 'codec': 0.16; 'file1': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'string:': 0.16; 'subject: \n ': 0.16; 'subject:skip:u 10': 0.16; 'subject:unicode': 0.16; 'syntaxerror:': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'finished': 0.19; 'mechanism': 0.19; 'import': 0.22; 'header :User-Agent:1': 0.23; 'bytes': 0.24; 'exists': 0.24; 'file.': 0.24; 'script': 0.25; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; "skip:' 10": 0.31; 'file': 0.32; 'option': 0.32; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'problem.': 0.35; 'but': 0.35; 'changing': 0.37; 'skip:o 20': 0.38; 'to:addr :python-list': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'solve': 0.60; 'simple': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'it!': 0.67; 'configparser': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=DZWZq5dW c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=SY9aFQKHIdAA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=pGLkceISAAAA:8 a=JaBlNa3EQuSd_LdB3MgA:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett@:2500 |
| Date | Fri, 08 May 2015 20:33:25 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape |
| References | <f4d02ce1-f528-4632-acb1-af667690a064@googlegroups.com> |
| In-Reply-To | <f4d02ce1-f528-4632-acb1-af667690a064@googlegroups.com> |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.261.1431113795.12865.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431113795 news.xs4all.nl 2848 [2001:888:2000:d::a6]:45021 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90193 |
Show key headers only | View raw
On 2015-05-08 20:00, zljubisicmob@gmail.com wrote: > The script is very simple (abc.txt exists in ROOTDIR directory): > > import os > import shutil > > ROOTDIR = 'C:\Users\zoran' > > file1 = os.path.join(ROOTDIR, 'abc.txt') > file2 = os.path.join(ROOTDIR, 'def.txt') > > shutil.move(file1, file2) > > > But it returns the following error: > > > C:\Python34\python.exe C:/Users/bckslash_test.py > File "C:/Users/bckslash_test.py", line 4 > ROOTDIR = 'C:\Users' > ^ > SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape > > Process finished with exit code 1 > > As I saw, I could solve the problem by changing line 4 to (small letter "r" before string: > ROOTDIR = r'C:\Users\zoran' > > but that is not an option for me because I am using configparser in order to read the ROOTDIR from underlying cfg file. > > I need a mechanism to read the path string with single backslashes into a variable, but afterwards to escape every backslash in it. > > How to do that? > If you're reading the path from a file, it's not a problem. Try it!
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-08 12:00 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape random832@fastmail.us - 2015-05-08 15:29 -0400
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-08 13:39 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-09 12:53 +1000
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-09 03:31 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Dave Angel <davea@davea.name> - 2015-05-09 08:25 -0400
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-10 14:10 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Dave Angel <davea@davea.name> - 2015-05-10 21:33 -0400
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-12 11:57 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-10 01:13 +1000
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Chris Angelico <rosuav@gmail.com> - 2015-05-10 01:22 +1000
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape zljubisicmob@gmail.com - 2015-05-10 14:14 -0700
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape MRAB <python@mrabarnett.plus.com> - 2015-05-08 20:33 +0100
Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Chris Angelico <rosuav@gmail.com> - 2015-05-09 08:54 +1000
csiph-web