sorry wenn das eine einfache newbie Frage ist, aber ich kapier es nicht:
Text file:
Code: Alles auswählen
gudrun:1052235700
schabanak:1014850400
teset:1054936800
stop:232342342
32days:1049407200
haaaaa:290923092
hello:1049407200
Code: Alles auswählen
#!/usr/bin/python
# import modules
import string
from time import time
from sys import exit
# open flat file database
try:
fp = open('free_subs.db', 'r+')
except IOError:
print 'Error opening file'
exit(1)
# read data
entries = []
for line in fp:
tokens = string.split(line, ':', 1)
if(len(tokens) > 1):
entries.append([tokens[0], string.rstrip(tokens[1])])
# create minimum timestamp (timestamp one month ago)
minimum = int(time() - 2592000)
# find overdue users
users_overdue = []
for user, since in entries:
if int(since) < int(minimum):
users_overdue.append(user)
entries.remove([user, since])
print entries
print users_overdue
Code: Alles auswählen
[['gudrun', '1052235700'], ['teset', '1054936800'], ['32days', '1049407200'], ['hello', '1049407200']]
['schabanak', 'stop', 'haaaaa']
Code: Alles auswählen
[['gudrun', '1052235700'], ['teset', '1054936800']
['schabanak', 'stop', '32days', 'haaaaa', 'hello']