python中的complex()函数
python中的complex()函数 1. complex()函数用于创建一个复数或者将一个数或字符串转换为复数形式,其返回值为一个复数。该函数的语法为: Help on class complex in module builtins: class complex(object) | complex(real=0, imag=0) | | Create a complex number from a real part and an optional imaginary part. #image默认为0 | | This is equivalent to (real + imag*1j) where imag defaults to 0. | | Methods defined here: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __bool__(self, /) | self != 0 | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /)