from time import sleep
#字典【dick】是除列表意外pytho之中最灵活的内置数据结构。列表是有序的对象集合,字典是无序的 # 对象集合
#两者之间的区别在于:字典当中的元素是通过键来存取的,而不是通过偏移存取
#字典中“{}”标识。字典有索引(key)和他对应的值valre组成。
dict={}
dict['xk']='this is one'
dict['2']='this is tow'
xkdict={'name':'张三','code':123456,'sales':'red'}
sleep(3)
print(dict['xk'])#输出键为“xk”的值
print(dict['2'])#输出键为“2”的值
print(xkdict)#输出完整的字典
print(xkdict.keys())#输出所有的键
print(xkdict.values())#输出所有的值
sleep(3)
加号(+)是字符串连接运算符,星号(*)是重复操作
#and,a为x,a and c 返回x,否则返回c的值
#or,a有字符,非0,返回a的值,否则返回c的值
#not,意思就是a=1,返回0 a=0,返回1
a=3.1415926757148
c=20
print(((a+c)**c))
sleep(5)
a=00
s=20
d=90.1024
if s+d<=a:
print('s+d等于a',a)
else:
print('s+d大于a',s+d)
sleep(5)
if a or d:
print(a)
else:
print(d)
if not (a and d):
print(a)
else:
print(d)
d=0
d %=a+s
print('d的值为:',d)
sleep(5)
list=(12,45,1454)
eplist=('name','word','admin')
print(list)
print(list[0])
print(eplist[1:9])
print(list + eplist)
# in,在列表中找指定的类。找了就返回“有”,没找到就“没有”
#not in,在列表中找不到返回“有”,找到了返回“没有”(有点类似说反话)
a=c=3
f=e=8
list={1,2,3,4,5,6,}
if c in list:
print('c在字典中,可查询')
else:
print('c不在字典中,查询不到')
sleep(3)
if f not in list:
print('f不在给定列表中,不可查询')
else:
print('f在字典中,可查询')
这是昨学习实践的写的,还不太熟悉