小白教程
所有教程
关于
Search
172.71.254.145
172.71.254.145
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python func complex”的源代码
本页内容
上一节:
Python_func_import
下一节:
Python_func_hasattr
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:complex()}}[[Category:python3 built in functions|60]] = Python complex() 函数 = [[python built in functions|Python 内置函数]] == 描述 == '''complex()''' 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数。如果第一个参数为字符串,则不需要指定第二个参数。。 == 语法 == complex 语法: <sample title="" desc="" lang="python" hererun="1"> class complex([real[, imag]]) </sample> 参数说明: * real -- int, long, float或字符串; * imag -- int, long, float; == 返回值 == 返回一个复数。 以下实例展示了 complex 的使用方法: <sample title="" desc="" lang="python" hererun="1"> >>>complex(1, 2) (1 + 2j) >>> complex(1) # 数字 (1 + 0j) >>> complex("1") # 当做字符串处理 (1 + 0j) # 注意:这个地方在"+"号两边不能有空格,也就是不能写成"1 + 2j",应该是"1+2j",否则会报错 >>> complex("1+2j") (1 + 2j) </sample> [[python built in functions|Python 内置函数]]
返回至“
Python func complex
”。
上一节:
Python_func_import
下一节:
Python_func_hasattr