Create a data page display, enter the page number you want to view, display the specified data, 10 data per page

# Write code page display, a for loop, creating 300 data, the data type is not limited, such as: alex-1alex1 @ live.com1, alex -2alex2 @ live.com2, alex-3alex3 @ live.com3, alex- 4alex4 @ live.com4, alex-5alex5 @ live.com5 
page # prompt the user to view (from a start), when the user input designated page number, then display the specified data, 10 data per page,
if the user enters page non-decimal numbers, you are prompted to format the content of an error, re-enter

page_roll DEF ():
LIS = []
for I in Range (. 1, 301):
product_res = 'alex-' + STR (I) + 'Alex' + STR (I) + '@ Live.com' + STR (I )
lis.append (product_res)
The page_num = int (len (LIS) / 10)
the try:
J = int (iNPUT ( 'enter a page:') Strip ()).
IF J> 30 J or <. 1:
Print ( 'input page is not valid, the display is empty. Please reenter!')
elif J> =. 1 and J <= The page_num:
page_content_div LIS = [(J -. 1) 10:10 * J * -. 1]
Print ( '% of shows a content d:% S '% (J, page_content_div))
the except Exception AS E:
Print (' content format error, re-enter, the error is:% S '% E)


page_roll ()

Guess you like

Origin www.cnblogs.com/laosun0204/p/11127828.html