wyh551202 发表于 2022-8-26 16:41:35

2022-08-26 学习Python-Day9

今日学习列表P34,P35,P36
学习中我发现一个问题 sorted()的方法可以直接print,但是.sort必须单独声明下,不然print(t.sort(key=len)) 值为None,希望大家注意下{:10_272:} 。

t=['FishC','Apple','Book','banana','Pen']
print(sorted(t))
print(sorted(t,key=len))
t=['FishC','Apple','Book','banana','Pen']
t.sort(key=len)
print(t)


################################P34
x=+
print(x)
x=(1,2,3)+(4,5,6)
print(x)
x='123'+'456'
print(x)
x=*3
print(x)
x=(1,2,3)*3
print(x)
x='123'*3
print(x)
###########
s=
print(id(s))
s *=2
print(id(s))
t=(1,2,3)
print(id(t))
t=t*2
print(id(t))
###########
x=
y=
print(x is y)
print('Fish' in 'FishC')
x=
del x
print(x)
y=
y=[]
print(y)
x=
del x[::2]
print(x)
x=
x.clear()
print(x)
x=
del x[:]
print(x)
################################P35
list1=list('FishC')
print(list1)
tuple1=tuple('FishC')
print(tuple)
str1=str()
print(str1,type(str1))
############
s=
print(min(s))
t='FishC'
print(max(t))
s=[]
print(min(s,default='撒都没有'))
print(min(1,2,3,0,6))
############
print(len(range(2*100)))
############
s=
print(sum(s))
print(sum(s,start=100))
############
s=
s=sorted(s)
print(s)
print(sorted(s,reverse=True))
t=['FishC','Apple','Book','banana','Pen']
print(sorted(t))
print(sorted(t,key=len))
t=['FishC','Apple','Book','banana','Pen']
t.sort(key=len)
print(t)
s=
sr=reversed(s)
print(sr)
height=
height_reverse=list(reversed(height))
print(height_reverse)
s=list(reversed("FishC"))
print(s)
################################P36
x=
y=
print(all(x))
print(all(y))
seasons=['spring','summer','fall','winter']
s=enumerate(seasons)
print(s)
ss=list(enumerate(seasons))
print(ss)
x=
y=
xy=zip(x,y)
z='FishC'
xy=zip(x,y,z)
print(list(xy))
import itertools
xy=itertools.zip_longest(x,y,z)
print(list(xy))
mapped=map(ord,'FishC')
print(list(mapped))
mapped=map(pow,,)
print(list(mapped))
mapped=
print(list(mapped))
print(list(filter(str.islower,'FishC')))
##############
mapped =map(ord,'FishC')
for each in mapped:
    print(each)
print(list(mapped))
x=
y=iter(x)
print(y,type(y))
for i in range(len(x)):
    print(next(y))
   
页: [1]
查看完整版本: 2022-08-26 学习Python-Day9