|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
今日学习列表P34,P35,P36
学习中我发现一个问题 sorted()的方法可以直接print,但是.sort必须单独声明下,不然print(t.sort(key=len)) 值为None,希望大家注意下 。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=[1,2,3]+[4,5,6]
print(x)
x=(1,2,3)+(4,5,6)
print(x)
x='123'+'456'
print(x)
x=[1,2,3]*3
print(x)
x=(1,2,3)*3
print(x)
x='123'*3
print(x)
###########
s=[1,2,3]
print(id(s))
s *=2
print(id(s))
t=(1,2,3)
print(id(t))
t=t*2
print(id(t))
###########
x=[1,2,3]
y=[1,2,3]
print(x is y)
print('Fish' in 'FishC')
x=[1,2,3,4,5]
del x[1:4]
print(x)
y=[1,2,3,4,5]
y[1:4]=[]
print(y)
x=[1,2,3,4,5]
del x[::2]
print(x)
x=[1,2,3,4,5]
x.clear()
print(x)
x=[1,2,3,4,5]
del x[:]
print(x)
################################P35
list1=list('FishC')
print(list1)
tuple1=tuple('FishC')
print(tuple)
str1=str([1,2,3,4])
print(str1,type(str1))
############
s=[1,1,2,3,5]
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=[1,0,0,8,6]
print(sum(s))
print(sum(s,start=100))
############
s=[1,2,3,0,6]
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=[1,2,5,8,0]
sr=reversed(s)
print(sr)
height=[1,8,6,2,5,4,8,3,7]
height_reverse=list(reversed(height))
print(height_reverse)
s=list(reversed("FishC"))
print(s)
################################P36
x=[1,1,0]
y=[1,1,9]
print(all(x))
print(all(y))
seasons=['spring','summer','fall','winter']
s=enumerate(seasons)
print(s)
ss=list(enumerate(seasons))
print(ss)
x=[1,2,3]
y=[4,5,6,7,8,9]
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,[2,3,10],[5,6,3])
print(list(mapped))
mapped=[pow(2,5),pow(3,2),pow(10,3)]
print(list(mapped))
print(list(filter(str.islower,'FishC')))
##############
mapped =map(ord,'FishC')
for each in mapped:
print(each)
print(list(mapped))
x=[1,2,3,4,5]
y=iter(x)
print(y,type(y))
for i in range(len(x)):
print(next(y))
|
|