float to string conversion

Moshe Zadka moshez at zadka.site.co.il
Mon Dec 18 23:20:21 EST 2000


On Mon, 18 Dec 2000 19:00:54 GMT, deragon at 8d.com wrote:

>   I cannot figure out how to convert a float to a string (obviously,
>   I am new to python).

The ``str'' function will most types to strings.

str(1) --> "1"
str(1.0) --> '1.0'

But don't forget the formatting operator:

"here's a float: %s\n" % 1.0 --> "here's a float: 1.0\n"
-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!




More information about the Python-list mailing list