[Chicago] strange None tailing
Ted Pollari
pollari.lists at gmail.com
Tue Apr 16 21:24:22 CEST 2013
The print function adds a new line. Add a coma after it, i.e.:
def test(f):
print >>f, "zzzz",
or, if you can assume f always has a write method, the more correct way would be:
def test(f):
f.write("zzzz")
hope that helps,
Ted
p.s.: for a more verbose write-up, see: http://stackoverflow.com/questions/493386/how-to-print-in-python-without-newline-or-space
On Apr 11, 2013, at 9:41 PM, shangyu <yushang at outlook.com> wrote:
> Hi dear all,
> I've wrote the following Python code :
>
> def test(f):
> print >>f, "zzzz"
>
> def main():
> f = open("test.cfg","w")
> test(f)
> f.close(
> when open the test.cfg file I got the following lines
> zzzz
> None
More information about the Chicago
mailing list