bijna goed ...
os.rename(out_fp.name, fn.name)
AttributeError: 'str' object has no attribute 'name'
On 22 May 2013, at 09:42, Ronald Oussoren wrote:
> Veel te complex :-). Je kan bij het inlezen ipv. ``open(filename, 'r')``
> gebruik maken van ``open(filename, 'rU')`` zodat het file object al de
> conversie van DOS naar unix regelovergangen doet.
>
> import tempfile, os
>
> for fn in FILES:
> with tempfile.NamedTemporaryFile(delete=False, dir=os.path.dirname(fn)) as
> out_fp:
> with open(fn, 'rU') as in_fp:
> data = in_fp.read()
> out_fp.write(data)
>
> os.rename(out_fp.name, fn.name)
>
>
> Ronald
_______________________________________________
Python-nl mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-nl