鱼C论坛

 找回密码
 立即注册
查看: 1924|回复: 0

[学习笔记] 2022-08-26 学习Python-Day9

[复制链接]
发表于 2022-8-26 16:41:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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))
    
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-26 09:49

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表