At 08:33 PM 3/22/2011, monkeys paw wrote:
When i open a file in python, and then print the
contents line by line, the printout has an extra blank
line between each printed line (shown below):
>>> f=open('authors.py')
>>> i=0
>>> for line in f:
print(line)
i=i+1
if i > 14:
break
Try
print(line.rstrip())
Your 'line' text value must still have line endings in it. .rstrip()
will remove trailing whitespace on the right. print() will then do
its own line ending.
Answer I don't know: why are the line endings still in the text values?
author_list = {
'829337' : {
'author_name' : 'Carter, John',
'count' : 49,
'c2' : '0.102040816326531',
How can i print the file out without having an extra newline between
printed lines?
Thanks for the help all.
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list