[Tutor] Strange ways of opening a file
Dave Angel
d at davea.name
Wed Mar 28 18:57:27 CEST 2012
On 03/28/2012 06:17 AM, Yan, Xianming wrote:
> Hello,
>
Without a meaningful title, it's unclear just what your question is.
When you do a reply on the digest, delete all the parts that aren't
relevant to your post, and change the subject line to something appropriate.
> I'm new to studying python,
>
> Seems you don't have to import the argument module.
>
The standard library has no module called argument. If you want to
import a module, you need to write it, and save it to a file with a .py
extension. Or perhaps you've installed such a module from some internet
site.
> You can simply open the two files and write then to another file. By using file("xxxx.xx",r) can open a file with read, by using file("xxxx",w) can open a file with write.
>
The standard way to open a file is with the built-in open() function.
Otherwise your syntax is missing the quotes around the r and w. To open
a text file, use:
infile = open("xxxx", "r")
outfile = open("yyyy", "w")
> And then you can using xx.readline() to read a line from file, then xx.writeline() to write into another file.
>
Again, assuming the data is text.
> Hope this helps you.
>
> Thanks
> Xianming
--
DaveA
More information about the Tutor
mailing list