Python作业之分页显示内容
1 #coding:utf8
2 user_list =[]
3 for i in range(1,302):
4 tmp = "{'user':'alex-%s,'email':'alex%s@email.com','pwd':'pwd%s'}" %(i,i,i)
5 user_list.append(tmp)
6 while True:
7 user_choice = input("请输入页码:").strip()
8 if user_choice.isdecimal():
9 user_choice = int(user_choice)
10 if user_choice >0 and user_choice <=len(user_list)/10+1:
11 min = user_choice * 10 -10
12 max = user_choice *10
13 for item in user_list[min:max]:
14 print(item)
15 else:
16 print("你输入的页码不存在,最大只能为%d页。"%(len(user_list)/10 + 1))
17 else:
18 print("你输入的不是数字页面。。")