2022-08-30 学习Python-Day10
忙碌几天又回来充电学习了,补了下字典和集合P34-P41{:10_300:} ,课程已过一般还得继续加油###############################P37
###############################P38
x={
'吕布',
'关羽'
}
print(type(x))
y={
'吕布':'口口布',
'关羽':'关习习'
}
print(type(y))
print(y['吕布'])
y['刘备'] ='刘baby'
print(y)
a={'吕布': '口口布', '关羽': '关习习', '刘备': '刘baby'}
print(a)
b=dict(吕布='口口布', 关羽='关习习',刘备='刘baby')
print(b)
c=dict([('吕布','口口布'),('关羽', '关习习'),('刘备', '刘baby')])
print(c)
d=dict({'吕布': '口口布', '关羽': '关习习', '刘备': '刘baby'})
print(d)
e=dict({'吕布': '口口布', '关羽': '关习习'},刘备='刘baby')
print(e)
f=dict(zip(['吕布','关羽','刘备'],['口口布', '关习习','刘baby']))
print(f)
d =dict.fromkeys('Fish',250)
print(d)
d['F']=70
print(d)
d['C']=67
print(d)
d.pop('s')
print(d)
d.pop('t','没有')
print(d.pop('t','没有'))
print(d.popitem())
print(d)
del d['i']
print(d)
d.clear()
print(d)
###############################P39
d=dict.fromkeys('FishC')
d['s']=115
print(d)
d.update(F='70',C='67',t='10')
print(d)
print(d['C'])
print(d.get('c','这里没有c'))
d.setdefault('c','code')
print(d)
keys = d.keys()
values = d.values()
items = d.items()
print(keys)
print(values)
print(items)
d.pop('c')
print(keys)
print(values)
print(items)
e=d.copy()
print(e)
print(len(d))
print('C' in d)
print(list(d))
print(list(d.values()))
e=iter(e)
print(list(reversed(d.values())))
d={'吕布':{'语文':60,'数学':70,'英语':80},'关羽':{'语文':80,'数学':90,'英语':70}}
print(d['吕布']['数学'])
d={'吕布':,'关羽':}
print(d['吕布'])
d={'F':70,'i':105,'s':115,'h':104,'C':67}
b={v:k for k,v in d.items()}
print(b)
c={v:k for k,v in d.items() if v>100}
print(c)
d={x:ord(x) for x in 'FishC'}
print(d)
d={x:y for x in for y in }
print(d)
###############################P40
print(type({}))
print(type({'one'}))
print(type({'one':1}))
a={'FishC','Python'}
print({s for s in 'FishC'})
print(set('FishC'))
s=set('FishC')
print('C' in s)
print(set())
s=
print( len(s)==len(set(s)))
t =s.copy()
s = set('FishC')
print(s.isdisjoint(set('Python')))
print(s.isdisjoint(set('JAVA')))
print(s.issuperset(set('Fish')))
print(s.union({1,2,3}))
print(s.intersection('Fish'))
print(s.difference('Fish'))
###############################P41
t=frozenset('FishC')
print(t)
s=set('FishC')
print(s)
s.update(,'23')
print(s)
s.intersection_update('FishC')
print(s)
s.symmetric_difference_update('Python')
print(s)
s.add('45')
print(s)
s.remove('o')
s.discard('aa')
s.clear()
print(hash(1.001))
print(hash((1,2,3)))
页:
[1]