Hi all,

I am trying to write float numbers in a file.
But it gave me an error "argument 1 must be string or read only character not float"
then i change it to


xyz = 0.9878
text = f.write(str(xyz))
now the error is .. 'str' object is not callable"

Can somebody help me with this?

Thanks in advance

I am guessing that you used 'str' as a variable name.

>>> str = 'abc'
>>> print str(123.456)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: 'str' object is not callable
>>> del str
>>> print str(123.456)
123.456
>>>

Thank you so much for ur quick response

and u r right i did use srt as a variable name
thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.