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 <cjwelb...@live.com>
  http://welbornprod.com

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to