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

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -