471,046 Members | 1,287 Online

# Convert float to string ...

Hi,

a simple question but i found no solution:

How can i convert a float value into a string value?
string_value1 = string(float_value) + ' abc'
doesn't work ...

Thanks
Aug 23 '05 #1
5 174858
On 2005-08-23, Konrad Mühler <ko****@my-rho.de> wrote:
Hi,

a simple question but i found no solution:

How can i convert a float value into a string value?
string_value1 = string(float_value) + ' abc'

string_value1 = str(float_value) + ' abc'

Or the more versatile:

string_value1 = "%10.3f abc" % float_value

--
Grant Edwards grante Yow! I'm having a BIG
at BANG THEORY!!
visi.com
Aug 23 '05 #2
On 8/23/05, Konrad Mühler <ko****@my-rho.de> wrote:
How can i convert a float value into a string value?

string_value1 = string(float_value) + ' abc'

string_value1 = str(float_value) + ' abc'

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Aug 23 '05 #3
Hi,

a simple question but i found no solution:

How can i convert a float value into a string value?

just use the "str" built-in type:
f = 9.99
str(f)

'9.99'
--
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
Aug 23 '05 #4
> How can i convert a float value into a string value?

Try:
string_value1 = str(float_value) + ' abc'
or:
string_value1 = repr(float_value) + ' abc'
Type in an interactive python session.
help(str)
or:
help(repr)
regards
Matt
--

| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
Aug 23 '05 #5
a simple question but i found no solution:

How can i convert a float value into a string value?
string_value1 = string(float_value) + ' abc'

str(float_value) + 'abc'

repr(float_value) + "abc"

'%fabc' % float_value

'%gabc' % float_value

(etc)

http://docs.python.org/tut/node9.html

</F>

Aug 23 '05 #6

### This discussion thread is closed

Replies have been disabled for this discussion.