Gang....
I'm writing the results of a function to a file. Just a text file and here's what i've done
>>> fn = open("c:/Python25/debt.txt", 'w')
>>> fn.write(debtcheck())
['"$ 8 , 8 1 5 , 7 3 6 , 9 1 3 , 5 9 2 . 8 0 ">']
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
TypeError: argument 1 must be string or read-only character buffer, not None
If it makes a difference... when I do just print debtcheck() I get both a numerica response and then on the next line it says "none", as seen below
>>> print debtcheck()
['"$ 8 , 8 1 5 , 7 4 4 , 1 2 5 , 6 4 2 . 1 5 ">']
None
What am I doing wrong for a the contents of debtcheck not being printing to the text file?
Thanks
PC
I am guessing that your function debtcheck() prints the string or list ['"$ 8 , 8 1 5 , 7 4 4 , 1 2 5 , 6 4 2 . 1 5 ">'].
print always returns None. It will work if debtcheck() does this:
- def debtcheck():
-
return str(['"$ 8 , 8 1 5 , 7 4 4 , 1 2 5 , 6 4 2 . 1 5 ">'])