hosts=['172.25.254.'+str(i) for i in range(101)]
class Page(object):
def __init__(self,current_page,per_items):
self.__current_page =current_page
self.__per_items=per_items
@property
def start(self):
val=(self.__current_page-1)*self.__per_items
return val
@property
def end(self):
val =self.__current_page*self.__per_items
return val
p = Page( 1,5)
print hosts[p.start:p.end]
—->>结果
['172.25.254.0', '172.25.254.1', '172.25.254.2', '172.25.254.3', '172.25.254.4']