python - How to convert the string '1.000,0.001' to the complex number (1+0.001j)? -
the best come is
s = '1.000,0.001' z = [float(w) w in s.split(',')] x = complex(z[0],z[1])
is there shorter, cleaner, nicer way?
there's more concise way, it's not cleaner , it's not clearer.
x = complex(*[float(w) w in '1.000,.001'.split(',')])
Comments
Post a Comment