Python 内置函数 complex() 详解 complex() 函数用于创建一个实部为 Real、虚部为 Imag 的复数,或将一个字符串、整数、浮点数等转换为复数。如果第一个参数是字符串,则不需要提供第二个参数。 下面给出 complex() 的语法:complex([Real[, Imag]])Real — int、long、float 或字符串;Imag — int、long、float; 返回一个复数对象。下面展示了使用 complex() 的示例: