lst = [1,2,3,4,5,'66565656']
lst1 = list('hellowordld')
lst3 = list(range(1,10,2))
print(lst)
print(lst1)
print(lst+lst1+lst3)
print(lst*3)
print(len(lst))
print(max(lst3))
print(min(lst3))
print(lst1.count('o'))
print(lst3.count('o'))
lst4 = [10,20,30]
print(lst4)
del lst4
lst5=['hello','world','py','php']
for item in lst5:
print(item)
for i in range(len(lst5)):
print(i,'-->', lst5[i])
for index, item in enumerate(lst5):
print(index,item)
for index, item in enumerate(lst5,1):
print(index,item)
list2=['apple','orange','banaba']
list2.sort()
list2.sort(reverse=True)
print('降序',list2)
list3=[3,34,34,5,6,57,6,22,78,68]
asclst=sorted(list3)
print(asclst)
desclist=sorted(list3,reverse=True)
print(desclist)
list111= [
['城市', '环比', '同比'],
['北京',102, 103],
['上海',104,504]
]
print(list111)
for row in list111:
for item in row:
print(item, end='\t')
print()
list2222= [[j for j in range(5)] for i in range(4)]
print(list2222)
s='helloworld'
for i in range(0,len(s)):
print(i, s[i])
for i in range(-10,0):
print(i,s[i])
s='hellowworld'
s1=s[0:5:1]
print(s1)
print(s[:5:1])
print(s[:5])
print(s[0::1])
print(s[5:])
print(s[0:5:2])
print(s[::2])
print(s[::-1])
s='hello'
s1='world'
s=s+s1
print(s)
list=[10,20,30,'ph']
print(s*5)
print('_'*40)
print('e' in s)
print('v' in s)
print('e' not in s)
print('v' not in s)
print(len(s))
print(max(s))
print(min(s))
print(s.index('o'))
print(s.count('o'))
t=('hello', [10,20],'py')
print(t)
t1=tuple('hello')
print(t1)
t=tuple([10,20,30,40])
print(t)
t=tuple(range(1,10))
print(t)
print('10在元组中么?', (10 in t))
print('10不在元祖中', (10 not in t))
print('max',max(t))
print('min',min(t))
print('len',len(t))
print('t.index',t.index(1))
print('t.count',t.count(3))
x=(10)
print(x,type(x))
y=(10,)
print(y,type(y))
del t
t=('python','hello','world','sad')
print(t[0])
print(t[0:3:1])
print(t[0:3:2])
for i in range(len(t)):
print(i,t[i])
for index,item in enumerate(t):
print(index,'---->',item)
d={10:'cat',20:'dog',30: 'pig'}
print(d)
list1=[10,20,30,40]
list2=['qq','ww','ee','rr']
d1=zip(list1,list2)
print(d1)
d3=dict(d1)
print(d3)
d22=dict(cat=10,dog=20)
print(d22)
del d22
print('max',max(d))
print('min',min(d))
print('len',len(d))
print(d[10])
print(d.get(20))
for item in d.items():
print(item)
for key,value in d.items():
print(key,value)
dd={100: 'sdsada',200: 'fdbdd'}
dd[300]='mkmll'
print(dd)
keys=dd.keys()
print(keys)
print(list[keys])
print(tuple[keys])
values=dd.values()
print(values)
print(list[values])
print(tuple[values])
items1=dd.items()
print(items1)
集合
s={10,20,40,30}
print(s)
s=set()
s=set('helloworld')
sa=set([10,20,30,40,50,10])
print(s)
print(sa)
s1={'json','sdad','aaa','bbbb'}
a={1,2,3,4}
b={3,4,5,6}
print(a&b)
print(a.intersection(b))
print(b&a)
print(b.intersection(a))
print(a|b)
print(a.union(b))
print(b|a)
print(b.union(a))
print(a-b)
print(a.difference(b))
print(b-a)
print(b.difference(a))