Windows - create text file - (newb)

E

Ernesto

Can Python be used to create (and/or open, read, and write) a text file
in Windows (if the path is known) ?
 
J

Jorge Godoy

Ernesto said:
Can Python be used to create (and/or open, read, and write) a text file
in Windows (if the path is known) ?

Yes.

--
Jorge Godoy <[email protected]>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
 
L

Larry Bates

Yes.

To open file:

fp=open(r'C:\directory\filename.txt','r')

To open file to write to:

fp=open(r'C:\directory\filename.txt','w')

You probably need to go through the Python tutorial as
these items are covered.

-Larry Bates
 
E

epost2

Yes. You could do:

Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
On Windows, for the path to your file, you could write
r'C:\myfile.txt' (if C:\ is a place you can write to.)

also, see the output from
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top