python基础,构建一个301个字典库

user_list = []
i = 0
while i <= 300:
name = 'alex -%d' %(i+1)
eml = 'alex%d@live.com'%(i+1)
pwd = 'pwd%d' %(i+1)
dict = {}
dict ["username"] = name
dict ["emal"] = eml
dict ["password"] = pwd
user_list.append(dict)
i += 1
for data in user_list:
print(data)

while True:
user_choice = input("请输入页码:")
user_choice.strip()
if user_choice.isdecimal():
user_choice = int(user_choice)
if user_choice > 0 and user_choice <= int(len(user_list)/10+1):
min = user_choice*10-10
max = user_choice*10-1
if max>300:
max = 300
start = min
while start <= max:
print(user_list[start])
start += 1
else:
print("你输入的页码不存在")
else:
print("请重新输入")
posted @ 2017-08-21 13:51  巡山的小钻风  阅读(186)  评论(0编辑  收藏  举报