How to a turn a list of strings into complex numbers in python?

前端 未结 5 719
刺人心
刺人心 2021-01-19 19:33

I\'m trying to write code which imports and exports lists of complex numbers in Python. So far I\'m attempting this using the csv module. I\'ve exported the data to a file u

5条回答
  •  借酒劲吻你
    2021-01-19 20:23

    I think each method above is bit complex

    Easiest Way is this

    In [1]: complex_num = '-2+3j'
    
    In [2]: complex(complex_num)
    Out[2]: (-2+3j)
    

提交回复
热议问题