番茄动漫网

番茄动漫网 > 动漫游戏

PythonThebeginning....

时间:2024-04-27 19:39:21来源:动漫游戏

数据类型

浮点:1.23e9=-0.=0.12e-7整数中间可以加横线:=10-000-000字符用''或””分割。如果是单引号,可以“‘”或者’\‘’\是普通的转意,通用。r''可以不转义(r'Thisisatest\',Yes!'):Thisisatest\',Yes!如果不好阅读'''...'''也可以。('''......''')布尔And:(53and57)_TureNot:not12Trueage=3ifage=10:('\n')else:('\n')


+++++空值:NULL

除法:
/:正确的。

//:只取整数部分

%:得到余数

(10/3)
(70//10)
(24%3)
(29%7)
3.


,,,,,?,,,

支持

和UTF-8的关联,计算机系统通用的字符编码工作方式:在计算机内存中,统一使用编码,当需要保存到硬盘或者需要传输的时候,就转换为UTF-8编码。

('是可以支持中文的')



对于单个字符的编码,提供了ord()函数获取字符的整数表示,chr()函数把编码转换为对应的字符:
(ord('A'),'玩:',ord('玩'),chr(67),chr())

类型的数据:b''或b""

字符串,用('')转为,反向是('')
(''.(''))
('**'.('utf-8'))
#把改成str
(b''.('utf-8'))
(b'\xe5\x82\xbb\xe9\x90\xbc'.('utf-8'))

获得长度的函数islen()

(len('')):9
(len('训养')).:2.

Thisistheofthestris..

Ifyouwanttohavetheofthe,thendoasthis:

(len(b'Joe')):3

(len(b'\xe5\x82\xbb\xe9\x90\xbc')).:6

(len('**'.('utf-8'))).:6

List


[]to:


=['Rob','','']


('Myare:')

()


输出:

Myare:

['Rob','',‘']


好像不是想要的

可以用下标获得内容。

([2])


长度函数:len

len()列表的元素数量

len()-1:最后一个的下标。



([len()-1])

(len()-1)


[len()-1]=[-1]:最后一个元素


toaddanewtothelist:

.(‘’)

(,)

Toanintothelistto

.(2,’Ken')


Pop()

Tothelast

.pop()

pop(i)

Toith

.pop(2)




Thelist.Itsbeonceitis.(()to)


=(M1,M2,M3)


Iftheonlyisa,itbesetas:

=(3,):

itwillbeasthe3ofa.




:


If:

The..

Elif:

The

Else:

Whatitwillbe.


('HowOldareyou?')

age=()

ifage=40:

('youare',age,'old.Youmustbe')

('Butyouhavelotsof.')

elifage=41:

('No,youhaveinyourlife')

else:

("youare",age,"old.Youareasgoodasdead.”)



:

For…in…

('Myinfor--inloopare:')

forin:

()


#toadd1-10


sum=0

foriin(1,2,3,4,5,6,7,8,9,10):

sum=sum+i

('Now,timetoshowthe,1++10is:')

(sum)



willalistof.

(101):will1…100


sum=0

foriin(101):

#(i)

sum=sum+i

('Now,timetoshowthe,1++100is:')

(sum)


====5050


loop:

Totheeven100:


('Theofeven0-100is:')

sum=0

=100


:

sum=sum+

=-2

(sum)

==2550


('Theofodd0-100is:')

sum=0

=99


:

sum=sum+

=-2

(sum)


===2500


inaloop:


('Totheofinaloop')

('Theofodd0-100is:')

sum=0

=100

:

=-1

if%2==0:

格斗动漫|亲子动漫|生活动漫|励志动漫|文艺动漫|青春动漫|推理动漫|悬疑动漫|热血动漫|校园动漫|

番茄动漫网