Unable to write % character to a file using writelines() method

dudeja.rajat at gmail.com dudeja.rajat at gmail.com
Sun Sep 28 17:47:51 CEST 2008


I'm using the writelines() method to write some lines to a text file. But
I'm unable to write the % character to the file using the following format:

fdTolFile.writelines("\n\tdiff Not in %s '%' range" %(toleranceInPer))

The second % does not get write to the file and Im getting errors. Please
suggest what additional information should I give to write the % character.

The errro Im getting is :
 File "C:\Documents and
Settings\\TA-workspace\src\TestAndCompareResults.py", line 840, in
    fdTolFile.writelines("\n\tdiff in %s'%' range" %(toleranceInPer))
TypeError: not enough arguments for format string

I've also tried this:

fdTolFile.writelines("\n\tdiff Not in %s \% range" %(toleranceInPer))

But still I get the same error

Thanks and regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080928/f4bf7557/attachment.html>

More information about the Python-list mailing list