首頁 >後端開發 >Python教學 >python函數 - complex()

python函數 - complex()

高洛峰
高洛峰原創
2016-10-17 14:55:061281瀏覽

complex([real[, imag]])

中文說明:

建立一個值為real + imag * j的複數或轉換一個字串或數為複數。如果第一個參數為字串,則不需要指定第二個參數。

參數real: int, long, float或字串;

參數imag: int, long, float。

英文說明:

Create a complex number with the value real + imag*j or convert a string or number to a complex number. If the first parameter is a string, it will be interpre as .com be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the function serves ) the function es ) consuncion likes conuncion . , long() and float(). If both arguments are omitted, returns 0j.

Note When converting from a string, the string must not contain whitespace around the central + 或 - operator. Forplex example, contain whitespace(12 月') is fine, but complex('1 + 2j') raises ValueError.

The complex type is described in Numeric Types — int, float, long, complex.


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn