Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # stores index of list or iterable to file, retrives count
- def store_counter(counter):
- # Store the counter value to a file
- with open('counter.txt', 'w') as file:
- file.write(json.dumps(counter))
- def retrieve_counter():
- # Retrieve the counter value from the file
- with open('counter.txt', 'r') as file:
- counter = json.load(file)
- return counter
- def main():
- try:
- counter = retrieve_counter()
- except FileNotFoundError:
- counter = 0
- for i in player_links[counter:]:
- # do somthing
- counter += 1
- store_counter(counter)
Advertisement