1 / 61

Python程序设计-第三章常用数据结构.ppt

Python程序设计-第三章常用数据结构.ppt

&gt;&gt;&gt;a=3
&gt;&gt;&gt;b=4
&gt;&gt;&gt;a+1
4
&gt;&gt;&gt;a-1
2
&gt;&gt;&gt;b*3
12
&gt;&gt;&gt;b/2
2
&gt;&gt;&gt;a%2
1
&gt;&gt;&gt;b**2
16
&gt;&gt;&gt;**b

&gt;&gt;&gt;c*2
Traceback(mostrecentcalllast):
File&quot;&lt;interactiveinput&gt;&quot;,line1,in&lt;module&gt;
NameError:name&#39;c&#39;isnotdefined
&gt;&gt;&gt;b/2+a
5
&gt;&gt;&gt;b/(+a)

&gt;&gt;&gt;printb/(+a)

&gt;&gt;&gt;num=1/
&gt;&gt;&gt;num

&gt;&gt;&gt;printnum

&gt;&gt;&gt;&quot;%e&quot;%num
&#39;-01&#39;
&gt;&gt;&gt;&quot;%&quot;%num
&#39;&#39;
&gt;&gt;&gt;

octhex

&gt;&gt;&gt;oct(64)
&#39;0100&#39;
&gt;&gt;&gt;hex(64)
&#39;0x40&#39;
&gt;&gt;&gt;int(&#39;0100&#39;)
100
&gt;&gt;&gt;int(&#39;0100&#39;,8)
64
&gt;&gt;&gt;int(&#39;0x40&#39;,16)
64
&gt;&gt;&gt;&quot;%o%x%X&quot;%(64,64,255)
&#39;10040FF&#39;

math模块-普通数学函数
cmath模块-处理复数的模块
&#39;acos&#39;,
&#39;fsum&#39;,
&#39;acosh&#39;,
&#39;hypot&#39;,
&#39;asin&#39;,
&#39;isinf&#39;,
&#39;asinh&#39;,
&#39;isnan&#39;,
&#39;atan&#39;,
&#39;ldexp&#39;,
&#39;atan2&#39;,
&#39;log&#39;,
&#39;atanh&#39;,
&#39;log10&#39;,
&#39;ceil&#39;,
&#39;log1p&#39;,
&#39;copysign&#39;,
&#39;modf&#39;,
&#39;cos&#39;,
&#39;pi&#39;,
&#39;cosh&#39;,
&#39;pow&#39;,
&#39;degrees&#39;,
&#39;radians&#39;,
&#39;e&#39;,
&#39;sin&#39;,
&#39;exp&#39;,
&#39;sinh&#39;,
&#39;fabs&#39;,
&#39;sqrt&#39;,
&#39;factorial&#39;,
&#39;tan&#39;,
&#39;floor&#39;,
&#39;tanh&#39;,
&#39;fmod&#39;,
&#39;trunc&#39;
&#39;frexp&#39;,
&#39;acos&#39;,
&#39;log&#39;,
&#39;acosh&#39;,
&#39;log10&#39;,
&#39;asin&#39;,
&#39;phase&#39;,
&#39;asinh&#39;,
&#39;pi&#39;,
&#39;atan&#39;,
&#39;polar&#39;,
&#39;atanh&#39;,
&#39;rect&#39;,
&#39;cos&#39;,
&#39;sin&#39;,
&#39;cosh&#39;,
&#39;sinh&#39;,
&#39;e&#39;,
&#39;sqrt&#39;,
&#39;exp&#39;,
&#39;tan&#39;,
&#39;isinf&#39;,
&#39;tanh&#39;
&#39;isnan&#39;,
random模块

&gt;&gt;&gt;importrandom
&gt;&gt;&gt;()

&gt;&gt;&gt;(1,10)
5
&gt;&gt;&gt;([&#39;a&#39;,&#39;b&#39;,&#39;c&#39;])
&#39;c&#39;

Unicode字符串

\newline

\\

\’

\”

\a

\b

\f

\n

\r

\t

\v

\uhhhh
Unicode16位的十六进制值
\Uhhhh…
Unicode32位的十六进制值
\xhh

\0oo

\0
Null
\other