Python complex() 函数
Python 教程
· 2019-02-01 16:27:46
描述
complex() 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数。如果第一个参数为字符串,则不需要指定第二个参数。。
语法
complex 语法:
class complex([real[, imag]])
参数说明:
- real -- int, long, float或字符串;
- imag -- int, long, float;
返回值
返回一个复数。
实例
以下实例展示了 complex 的使用方法:
>>>complex(1, 2)
(1 + 2j)
>>> complex(1) # 数字
(1 + 0j)
>>> complex("1") # 当做字符串处理
(1 + 0j)
# 注意:这个地方在"+"号两边不能有空格,也就是不能写成"1 + 2j",应该是"1+2j",否则会报错
>>> complex("1+2j")
(1 + 2j)
点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html
Masterminds of Programming
Federico Biancuzzi、Chromatic / O'Reilly Media / 2009-03-27 / USD 39.99
Description Masterminds of Programming features exclusive interviews with the creators of several historic and highly influential programming languages. Think along with Adin D. Falkoff (APL), Jame......一起来看看 《Masterminds of Programming》 这本书的介绍吧!
RGB HSV 转换
RGB HSV 互转工具
RGB CMYK 转换工具
RGB CMYK 互转工具