A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/327679.html below:

Equivalent for an internal write in Python ?

Equivalent for an internal write in Python ? Equivalent for an internal write in Python ?Fredrik Lundh fredrik at pythonware.com
Thu Sep 1 15:53:55 EDT 2005
Madhusudan Singh wrote:

> I am looking to write a formatted string to a string variable :
>
> Say I have 1.067e-01, I need to write 106.700 to some string.
>
> In Fortran 95, this would be accomplished with a :
>
> character(len=7) :: stringvar
> real :: stringval
>
> ...
>
> write(stringvar,'(f7.3)') stringval
>
> How does one do something like this in Python ? I need a string formatted in
> this way for one of my applications.

    stringvar = "%.3f" % stringval

for details, see

    http://docs.python.org/tut/node9.html
    http://docs.python.org/lib/typesseq-strings.html

</F> 




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4