On Jan 12, 6:21 pm, MRAB wrote:
> On 12/01/2012 22:26, Denhua wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I've got a file which I'd like to read, modify and write.
>
> > # file contents
> > a
> > b
> > c
> > d
>
> > My script reads the file contents into a list and rotates the list and
> > writes it back t
On 12/01/2012 22:26, Denhua wrote:
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
whe
In article
<4f7d125a-2713-4b57-a108-2a56ae653...@h3g2000yqe.googlegroups.com>,
Denhua wrote:
> [omitted]
> f.write("\n".join(newlist))
> f.close()
>
> # output
>
> [root@Inferno html]# python rotate.py
> ['b', 'c', 'd', 'a']
> [root@Inferno html]# python rotate.py
> ['c', 'd', 'a', '\x00\x00\
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
where they are coming from.
#!/usr/bin/