Answers for "str to tuple of float"

0

str to tuple of float

x = str((1, 20, 2.0))
 
y = tuple(float(s) for s in x.strip("()").split(","))
print(y)
(1.0, 20.0, 2.0)
Posted by: Guest on March-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language