Python> tuple> (3., 1., 4.) to 3.00000, 1.00000, 4.00000 (decimal point to 5 digits)> Use .join

Operating environment


Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 
Python 3.6.0 on virtualenv

I'm trying to do the title.

http://qiita.com/7of9/items/4aa9f546a4ff1bf2e1aa I was taught various methods in the comments.

Separately, I found the following. http://stackoverflow.com/questions/15968017/formatting-a-tuple-of-floats

I implemented this.

test_python_170324b.py


import numpy as np

atuple = (3., 1., 4., 1., 5., 9., 2., 6., 5., 3., 5.)

astr=','.join(format(elem, '.5f') for elem in atuple)
print(astr)

result


$ python test_python_170324b.py 
3.00000,1.00000,4.00000,1.00000,5.00000,9.00000,2.00000,6.00000,5.00000,3.00000,5.00000

There seem to be various ways to do it, and I'm considering what I can use "in the sky" (and what is highly readable).

Matters taught

(Addition 2017/03/24)

I think @ shiracamus's Comment is simpler and easier to read.

Thank you for the information.

Recommended Posts

Python> tuple> (3., 1., 4.) to 3.00000, 1.00000, 4.00000 (decimal point to 5 digits)> Use .join
Python decimal point handling
[Python] How to use hash function and tuple.
Display n digits after the decimal point in python
Show decimal point in Python
python3: How to use bottle (2)
[Python] How to use list 1
How to use Python argparse
Python: How to use pydub
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
[Python] Summary of how to use split and join functions
Python: How to use async with
[Python] How to use Pandas Series
How to use Requests (Python Library)
How to use SQLite in Python
[Introduction to Python] Let's use pandas
[Python] How to use list 3 Added
How to use Mysql in python
How to use OpenPose's Python API
How to use ChemSpider in Python
How to use FTP with Python
Python: How to use pydub (playback)
How to use PubChem in Python
Easy to use Jupyter notebook (Python3.5)
Convert decimal numbers to n-ary numbers [python]
[Introduction to Python] Let's use pandas
How to use python zip function
[Introduction to Python] Let's use pandas
[Python] How to use Typetalk API
Python> tuple> Convert double tuple to single tuple
[Introduction to Python] How to use class in Python?
[Python] Use pandas to extract △△ that maximizes ○○
[Road to intermediate Python] Use ternary operators
How to install and use pandas_datareader [Python]
[Introduction to Udemy Python3 + Application] 21. Tuple type
[python] How to use __command__, function explanation
I want to use jar from python
Transfer floating point data from Python to JavaScript without loss of digits
[Introduction to Python] Let's use foreach with Python
Easy way to use Wikipedia in Python
[Python] Organizing how to use for statements
Memorandum on how to use gremlin python
python> Convert tuple to list> aList = list (pi_tuple)
[Python2.7] Summary of how to use unittest
python: How to use locals () and globals ()
How to use __slots__ in Python class
Install python on xserver to use pip
How to use "deque" for Python data
How to use Python zip and enumerate
[Python] Understand how to use recursive functions
Summary of how to use Python list
[Road to intermediate Python] Use lambda expressions
How to use regular expressions in Python
[Python2.7] Summary of how to use subprocess
How to use is and == in Python
[Blender x Python] How to use modifiers