473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 175335
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
4
by: STom | last post by:
How do you convert a string in C# to decimal? STom
15
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
4
by: Pixie Songbook | last post by:
Hi, I'm trying to write a program using the Dev C++ 4.9.9.2 compiler that takes input numbers from a word document, sums them together, and then gives me a result. It should be easy as the book I...
3
by: priyanka | last post by:
Hi there, I want to convert a String into integer. I get the string from a file using : string argNum; getline(inputStream,argNum); I now need to convert argNum into integer.
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
2
by: lisasahu | last post by:
how to convert float to string like there is atof atoi and itoa but is ther any method to convert float to string
5
by: sidhuasp | last post by:
Hi could anyone please tell me how to convert float value in my database ti HOUR/MIN format for my timesheet requirement. i have to do it in sql-reporting services
3
by: audrey29 | last post by:
How do i convert my string to float?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.