468,256 Members | 1,439 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,256 developers. It's quick & easy.

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
Konrad
Aug 23 '05 #1
5 174351
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
Konrad Mühler wrote:
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
Konrad Mühler wrote:
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)

the tutorial has more information:

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

</F>

Aug 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Convert TextBox.Text to Int32 Problem | last post: by
4 posts views Thread by STom | last post: by
15 posts views Thread by Yifan | last post: by
3 posts views Thread by priyanka | last post: by
2 posts views Thread by lisasahu | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.