Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107374

Re: Python path and append

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Python path and append
Date 2016-04-20 08:38 +1000
Message-ID <mailman.44.1461105533.30862.python-list@python.org> (permalink)
References <smbdhb5kjje2oandna4vj5udku9gh1h9oa@4ax.com> <CAPTjJmrCne5sz_gVPY1Q4fAOFgm0rr0rJL4kEMgjnPyg6SW3MA@mail.gmail.com>

Show all headers | View raw


On Wed, Apr 20, 2016 at 8:29 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
>
> handle = open("\\Winmx\New$\q.txt")
> for line in handle:
>     line=line.strip()
>     print line
>
>
> Traceback (most recent call last):
>   File "\\Winmx\New$\add viewed.py", line 2, in <module>
>     handle = open("\\Winmx\New$\q.txt")
> IOError: [Errno 2] No such file or directory: '\\Winmx\\New$\\q.txt'
>
> What I would like to do is read a plain text file from a hidden
> network drive and append a space and the * character to the end of
> each line.

Start with this:

print("\\Winmx\New$\q.txt")

If that doesn't do what you expect, it's possibly because you want to
use a raw string literal to prevent the backslashes from being parsed.

handle = open(r"\\Winmx\New$\q.txt")

That might help you.

(One clue that this is happening is that some of your backslashes got
doubled in the error message.)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-19 18:29 -0400
  Re: Python path and append Chris Angelico <rosuav@gmail.com> - 2016-04-20 08:38 +1000
  Re: Python path and append Matthew Barnett <mrabarnett@mrabarnett.plus.com> - 2016-04-20 00:36 +0100
  Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-25 14:10 -0400
    Re: Python path and append Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-25 18:24 +0000
      Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-25 15:00 -0400
        RE: Python path and append Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-04-25 19:08 +0000
          Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-25 16:15 -0400
            Re: Python path and append Random832 <random832@fastmail.com> - 2016-04-25 16:28 -0400
            Re: Python path and append Peter Otten <__peter__@web.de> - 2016-04-25 23:38 +0200
            Re: Python path and append Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-25 19:57 -0400
        Re: Python path and append Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-25 19:31 +0000
        Re: Python path and append MRAB <python@mrabarnett.plus.com> - 2016-04-25 20:44 +0100
          Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-25 16:43 -0400
        Re: Python path and append Steven D'Aprano <steve@pearwood.info> - 2016-04-26 11:51 +1000
          Re: Python path and append Dan Sommers <dan@tombstonezero.net> - 2016-04-26 01:59 +0000
          Re: Python path and append Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-26 18:23 +1200
          Re: Python path and append boB Stepp <robertvstepp@gmail.com> - 2016-04-29 15:26 -0500
            Re: Python path and append Steven D'Aprano <steve@pearwood.info> - 2016-04-30 11:44 +1000
    Re: Python path and append John Gordon <gordon@panix.com> - 2016-04-25 21:26 +0000
      Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-25 18:04 -0400
        Re: Python path and append Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-25 20:03 -0400
        Re: Python path and append Steven D'Aprano <steve@pearwood.info> - 2016-04-26 11:53 +1000
          Re: Python path and append Seymore4Head <Seymore4Head@Hotmail.invalid> - 2016-04-26 22:56 -0400
            Re: Python path and append Chris Angelico <rosuav@gmail.com> - 2016-04-27 13:06 +1000
            Re: Python path and append Stephen Hansen <me+python@ixokai.io> - 2016-04-27 17:24 -0700
      Re: Python path and append Chris Angelico <rosuav@gmail.com> - 2016-04-26 10:25 +1000

csiph-web