[Tutor] 答复: Tutor Digest, Vol 97, Issue 72

Yan, Xianming Xianming.Yan at intercallapac.com
Wed Mar 28 12:17:16 CEST 2012


Hello,

I'm new to studying python,

Seems you don't have to import the argument module.

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.

And then you can using xx.readline() to read a line from file, then xx.writeline() to write into another file.

Hope this helps you.

Thanks
Xianming

-----邮件原件-----
发件人: tutor-bounces+xianming.yan=intercallapac.com at python.org [mailto:tutor-bounces+xianming.yan=intercallapac.com at python.org] 代表 tutor-request at python.org
发送时间: 2012年3月28日 18:00
收件人: tutor at python.org
主题: Tutor Digest, Vol 97, Issue 72

Send Tutor mailing list submissions to
	tutor at python.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
	tutor-request at python.org

You can reach the person managing the list at
	tutor-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: I/O operation on closed file? (bob gailer)


----------------------------------------------------------------------

Message: 1
Date: Tue, 27 Mar 2012 10:16:36 -0400
From: bob gailer <bgailer at gmail.com>
To: thao nguyen <thaonphuong at gmail.com>
Cc: tutor at python.org
Subject: Re: [Tutor] I/O operation on closed file?
Message-ID: <4F71CBC4.7080109 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

in addition to posting the relevant code:
please in future use a meaningful subject which I have provided this time.
remember to reply-all so a copy goes to the list.

On 3/26/2012 9:08 PM, thao nguyen wrote:
>
> Dear Support Team,
>
> I have built a function (enclosed here) to merge many files (in this 
> example is 2 files: "a1.txt" and "a2.txt") lines by lines. The output 
> file is called "final_file". However, i could not have it run 
> successfully.
>
> Content of "a1.txt":
> 1
> 3
> 5
>
>
> Content of "a2.txt":
> 2
> 4
> 6
>
>
> Content of "final_file.txt" will be like:
> 1
> 2
> 3
> 4
> 5
> 6
>
>
> In Python, i called just written module:
>
> import argument
> reload(argument)
> argument.test(2,"C:/a1.txt","C:/a2.txt")
>
> and get the error as below:
>     "ValueError: I/O operation on closed file
>      File "c:\append.py", line 5, in <module>
>              argument.test(2,"C:/a1.txt","C:/a2.txt")
>      File "c:\argument.py", line 28, in test
>             for line_data in f:"
>
> Could you please advise the resolution for this?
>
What does " I/O operation on closed file" suggest to you?

-- 
Bob Gailer
919-636-4239
Chapel Hill NC



------------------------------

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 97, Issue 72
*************************************


More information about the Tutor mailing list