Pythoncomplex ()関数
例
数3と虚数5を複素数に変換します。
x = complex(3, 5)
定義と使用法
このcomplex()
関数は、実数と虚数を指定して複素数を返します。
構文
complex(real, imaginary)
パラメータ値
Parameter | Description |
---|---|
real | Required. A number representing the real part of the complex number. Default 0. The real number can also be a String, like this '3+5j', when this is the case, the second parameter should be omitted. |
imaginary | Optional. A number representing the imaginary part of the complex number. Default 0. |
その他の例
例
文字列を複素数に変換します。
x = complex('3+5j')