python中的<class ‘complex‘>

一般编程里面不怎么会讲,但是还是挺强大的一个类。

在 Python 中,<class 'complex'> 表示复数类型。复数是一种包含实部和虚部的数学数,可以用 a + bj 的形式表示,其中 a 表示实部,b 表示虚部,j 是虚数单位,等于 -1 的平方根。

Python 内置了对复数的支持,可以使用 complex 类来创建和操作复数。complex 类提供了许多方法和运算符,用于对复数进行各种操作,例如:
image.png

  • 创建复数:
    • 使用 complex(real, imag) 函数来创建一个新的复数,其中 real 是实部,imag 是虚部。
    • 可以直接使用 a + bj 的形式来创建复数,其中 a 是实部,b 是虚部,j 是虚数单位。
  • 访问复数的实部和虚部:
    • 使用 .real 属性来访问复数的实部。
    • 使用 .imag 属性来访问复数的虚部。
  • 复数运算:
    • 支持基本的算术运算,例如加减乘除、幂运算等。
    • 支持比较运算,例如等于、不等于、大于、小于等。
    • 支持一些特殊运算,
<?xml version="1.0" encoding="UTF-8"?> <svg width="2866" xmlns:cge="http://iec.ch/TC57/2005/SVG-schema#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2866 2027" height="2027"> <defs> <symbol id="terminal:端子" preserveAspectRatio="xMidYMid"> <circle cx="0.0" cy="0.0" r="1.0" visibility="hidden" stroke-width="1"/> </symbol> <symbol id="PolePSR:铁塔直线杆塔@0" preserveAspectRatio="xMidYMid" viewBox="0 0 14.0 14.0"> <use x="7.0" y="7.0" terminal-index="0" xlink:href="#terminal:端子"/> <polygon stroke="rgb(0,0,0)" points="1.0,1.0 13.0,1.0 13.0,13.0 1.0,13.0" stroke-width="1" fill="none"/> <line y1="1.3" y2="12.7" x1="12.7" x2="1.3" stroke="rgb(0,0,0)" stroke-width="1"/> <line y1="1.3" y2="12.7" x1="1.3" x2="12.7" stroke="rgb(0,0,0)" stroke-width="1"/> </symbol> <symbol id="Disconnector:柱上隔离开关@0" preserveAspectRatio="xMidYMid" viewBox="0 0 20.4 42.0"> <use x="10.2" y="1.0" terminal-index="0" xlink:href="#terminal:端子"/> <use x="10.2" y="41.0" terminal-index="1" xlink:href="#terminal:端子"/> <line y1="27.5" y2="41.0" x1="10.2" x2="10.2" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="10.3" y2="1.0" x1="10.2" x2="10.2" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="10.3" y2="10.3" x1="7.2" x2="13.2" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="26.4" y2="9.4" x1="10.0" x2="1.0" stroke="rgb(0,255,0)" stroke-width="1"/> </symbol> <symbol id="Disconnector:柱上隔离开关@1" preserveAspectRatio="xMidYMid" viewBox="0 0 20.4 42.0"> <use x="10.2" y="1.0" terminal-index="0" xlink:href="#terminal:端子"/> <use x="10.2" y="41.0" terminal-index="1" xlink:href="#terminal:端子"/> <line y1="27.5" y2="41.0" x1="10.2" x2="10.2" stroke="rgb(255,0,0)" stroke-width="1"/> <line y1="10.3" y2="1.0" x1="10.2" x2="10.2" stroke="rgb(255,0,0)" stroke-width="1"/> <line y1="10.3" y2="10.3" x1="7.2" x2="13.2" stroke="rgb(255,0,0)" stroke-width="1"/> <line y1="26.2" y2="8.8" x1="10.1" x2="5.9" stroke="rgb(255,0,0)" stroke-width="1"/> </symbol> <symbol id="Breaker:普通断路器@0" preserveAspectRatio="xMidYMid" viewBox="0 0 27.7 42.6"> <use x="13.9" y="1.1" terminal-index="0" xlink:href="#terminal:端子"/> <use x="13.9" y="41.1" terminal-index="1" xlink:href="#terminal:端子"/> <line y1="1.1" y2="10.6" x1="13.9" x2="13.9" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="41.1" y2="26.0" x1="13.9" x2="13.9" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="25.0" y2="10.1" x1="13.7" x2="4.9" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="8.1" y2="13.2" x1="17.9" x2="9.8" stroke="rgb(0,255,0)" stroke-width="1"/> <line y1="8.1" y2="13.1" x1="9.9" x2="17.9" stroke="rgb(0,255,0)" stroke-width="1"/> </symbol> <symbol id="Breaker:普通断路器@1" preserveAspectRatio="xMidYMid" viewBox="0 0 27.7 42.6"> <use x="13.9" y="1.1" terminal-index="0" xlink:href="#terminal:端子"/> <use x="13.9" y="41.1" terminal-index="1" xlink:href="#terminal:端子"/> <line y1="1.1" y2="10.6" x1="13.9" x2="13.9" stroke="rgb(255,0,0)" stroke-width="1"/> <line y1="8.1" y2="13.2" x1="17.9" x2="9.8" stroke="rgb(255,0,0)" stroke-width="1"/> <line y1="8.1" y2="13.1" x1="9.9" x2="17.9" stroke="rgb(255,0,0)" stroke-width="1"/> <polyline stroke="rgb(255,0,0)" points="13.9,41.2 13.9,25.2 7.9,8.1" stroke-width="1" fill="none"/> </symbol> <symbol id="Breaker:普通断路器@4" preserveAspectRatio="xMidYMid" viewBox="0 0 27.7 42.6"> <use x="13.9" y="1.1" terminal-index="0" xlink:href="#terminal:端子"/> <use x="13.9" y="41.3" terminal-index="1" xlink:href="#terminal:端子"/> <polygon stroke="rgb(255,0,255)" points="1.0,41.6 24.7,41.6 24.8,1.1 1.0,1.0" stroke-width="1" fill="rgb(255,255,112)"/> <line y1="1.1" y2="10.7" x1="13.9" x2="13.9" stroke="rgb(255,0,255)" stroke-width="1"/> <line y1="41.1" y2="26.1" x1="13.9" x2="14.0" stroke="rgb(255,0,255)" stroke-width="1"/> <line y1="25.1" y2="10.1" x1="13.7" x2="4.9" stroke="rgb(255,0,255)" stroke-width="1"/> <line y1="8.1" y2="13.2" x1="17.9" x2="9.9" stroke="rgb(255,0,255)" stroke-width="1"/> <line y1="8.1" y2="13.1" x1="9.9" x2="17.9" stroke="rgb(255,0,255)" stroke-width="1"/> </symbol> <symbol id="PolePSR:水泥杆直线杆塔@0" preserveAspectRatio="xMidYMid" viewBox="0 0 14.0 14.0"> <use x="7.0" y="7.0" terminal-index="0" xlink:href="#terminal:端子"/> <circle cx="7.0" cy="7.0" stroke="rgb(0,0,0)" r="6.0" stroke-width="1" fill="none"/> </symbol> <symbol id="Breaker:变电断路器@0" preserveAspectRatio="xMidYMid" viewBox="0 0 12.3 22.0"> <use x="6.1" y="0.6" terminal-index="0" xlink:href="#terminal:端子"/> <use x="6.1" y="21.6" terminal-index="1" xlink:href="#terminal:端子"/> <polygon stroke="rgb(255,0,0)" points="1.0,1.0 11.0,1.0 11.0,21.0 1.0,21.0" stroke-width="1" fill="none"/> </symbol> <symbol id="Breaker:变电断路器@1" preserveAspectRatio="xMidYMid" viewBox="0 0 12.3 22.0"> <use x="6.1" y="0.6" terminal-index="0" xlink:href="#terminal:端子"/> <use x="6.1" y="21.6" terminal-index="1" xlink:href="#terminal:端子"/> <polygon stroke="rgb(255,0,0)" points="1.2,1.0 11.2,1.0 11.2,21.0 1.2,21.0" stroke-width="1" fill="rgb(255,0,0)"/> </symbol> </defs> <g id="HeadClass"> <rect x="0" width="2866" y="0" FeederName="10kV羊街古城村线" stroke="rgb(255,255,255)" FeederID="547240133021800" stroke-width="4" height="2027" fill-opacity="1" fill="rgb(255,255,255)"/> </g> <g id="SubstationClass"> <g id="547240133044200"> <polygon stroke="rgb(0,0,0)" points="610.3,1056.8 610.3,960.8 816.3,960.8 816.3,1056.8" stroke-width="2" fill="none"/> <metadata> <cge:PSR_Ref ObjectID="SUBST_544050322075002" ObjectName="35kV大庄变"/> </metadata> </g> </g> <g id="OtherClass"/> <g id="PolePSRClass"> <g id="547240133025700"> <use x="886.3" width="14.0" y="1008.8" xlink:href="#PolePSR:铁塔直线杆塔@0" transform="rotate(0.0,893.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547050068712004" ObjectName=""/> </metadata> </g> <g id="547240133036000"> <use x="1050.3" width="14.0" y="1008.8" xlink:href="#PolePSR:铁塔直线杆塔@0" transform="rotate(0.0,1057.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547220660325100" ObjectName=""/> </metadata> </g> <g id="547240133036800"> <use x="1317.3" width="14.0" y="1008.8" xlink:href="#PolePSR:铁塔直线杆塔@0" transform="rotate(0.0,1324.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547220660326100" ObjectName=""/> </metadata> </g> <g id="547240133037600"> <use x="1561.3" width="14.0" y="1008.8" xlink:href="#PolePSR:铁塔直线杆塔@0" transform="rotate(0.0,1568.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547220660328400" ObjectName=""/> </metadata> </g> <g id="547240133039600"> <use x="1890.3" width="14.0" y="1009.0" xlink:href="#PolePSR:水泥杆直线杆塔@0" transform="rotate(0.0,1897.2,1016.0) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547050068424804" ObjectName=""/> </metadata> </g> <g id="547240133040400"> <use x="2102.3" width="14.0" y="1009.0" xlink:href="#PolePSR:水泥杆直线杆塔@0" transform="rotate(0.0,2109.2,1016.0) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547050068408704" ObjectName=""/> </metadata> </g> <g id="547240133041200"> <use x="2358.3" width="14.0" y="1008.8" xlink:href="#PolePSR:铁塔直线杆塔@0" transform="rotate(0.0,2365.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="14.0"/> <metadata> <cge:PSR_Ref ObjectID="POLE_547050068397504" ObjectName="10kV羊街古城村线10kV大草线"/> </metadata> </g> </g> <g id="DisconnectorClass"> <g id="547240133038400"> <use x="1578.0" width="20.4" y="994.8" xlink:href="#Disconnector:柱上隔离开关@1" transform="rotate(270.0,1588.2,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="42.0"/> <metadata> <cge:PSR_Ref ObjectID="SWITCH_547220660329200" ObjectName="G011"/> </metadata> </g> </g> <g id="BreakerClass"> <g id="547240133039000"> <use x="1614.4" width="27.7" y="994.5" xlink:href="#Breaker:普通断路器@1" transform="rotate(270.0,1628.3,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="42.6"/> <metadata> <cge:PSR_Ref ObjectID="SWITCH_547220660330200" ObjectName="10kV羊街古城村线#19杆G01断路器"/> </metadata> </g> <g id="547240133043100"> <use x="707.2" width="12.3" y="1004.8" xlink:href="#Breaker:变电断路器@1" transform="rotate(90.0,713.3,1015.8) scale(1.00000000,1.00000000) translate(0.0,0.0)" height="22.0"/> <metadata> <cge:PSR_Ref ObjectID="SWITCH_535220034655000" ObjectName="072"/> </metadata> </g> </g> <g id="ConnectiveLineClass"> <g id="547240133038001"> <path stroke="none" stroke-width="1" d="M1568.3,1015.8 L1568.3,1015.8" fill="rgb(0,0,0)"/> <metadata> <cge:CN_Ref LinkObjectIDnd="547240133037600@0" LinkObjectIDznd="547240133038400@0"/> </metadata> </g> <g id="547240133038801"> <path stroke="none" stroke-width="1" d="M1608.3,1015.8 L1608.3,1015.8" fill="rgb(0,0,0)"/> <metadata> <cge:CN_Ref LinkObjectIDnd="547240133038400@1" LinkObjectIDznd="547240133039000@0"/> </metadata> </g> </g> 这段代码是什么意思
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据小羊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值