Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61791
| From | Christopher Welborn <cjwelborn@live.com> |
|---|---|
| Subject | Re: Need help with file object |
| Date | 2013-12-12 22:54 -0600 |
| References | <CACDG_KfbVuPbBpMWVcgVMQLjZ5N+mm-oPAaqyPoBKV62cW80hA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4048.1386910472.18130.python-list@python.org> (permalink) |
On 12/12/2013 10:29 PM, Unix SA wrote:
> Hello,
>
> I am facing some issue when copying or moving file
>
> f=open('/tmp/file1')
> s=open('/tmp/file2')
>
> for line in f:
> if 'match' not in line:
> s.write(line)
>
> import shutil
> shutil.move(s, f)
>
> With above prog I am getting error
> TypeError: coercing to Unicode: need sting or buffer, file found
>
> What that means and how I can resolve it.
>
> Regards,
> Dj
>
>
>
You are sending the actual file objects to shutil.move, it is expecting
a string. Actually, strings containing the path to move and the
destination. Like this: shutil.move('/tmp/file2', '/tmp/file1')
--
- Christopher Welborn <cjwelborn@live.com>
http://welbornprod.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Need help with file object Christopher Welborn <cjwelborn@live.com> - 2013-12-12 22:54 -0600
csiph-web