何小萌萌萌果照,友情链接系统,诡婚
li = [] for i in range(1000): li.append(i) while True: p = input('input page: ') p = int(p) start = (p-1) * 10 end = p * 10 print(li[start:end]) 运行结果: input page: 1 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] input page: 2 [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] input page: 5 [40, 41, 42, 43, 44, 45, 46, 47, 48, 49] input page:
class Pagegenerate: def __init__(self, current_page): try: p = int(current_page) except Exception as e: p = 1 self.page = int(current_page) @property def start(self): val = (self.page-1) * 10 return val @property def end(self): val = self.page * 10 return val li = [] for i in range(1000): li.append(i) while True: p = input("Enter the page to view: ") obj = Pagegenerate(p) print(li[obj.start:obj.end]) 运行结果: Enter the page to view: 2 [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Enter the page to view: 5 [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
python求numpy中array按列非零元素的平均值案例
网友评论