can't read all data from file useing Python
inside test.txt there is :
{'God': {u'user1@localhost': {}, u'user2@localhost': {}, u'user3@localhost': {}}}
and the code is :
# coding: utf-8
def read_file(filename):
data=None
try:
fp = file(filename)
data = fp.read()
fp.close()
except: pass
return data
def read():
file = 'test.txt'
db = eval(read_file(file))
if "God" in db:
for x in db["God"]:
data = x
#print(x) $$ it'll print all data True but I do not need it, I will put instructions inside and I do not need to be repeated.
print(x) # $$ print just 1 data from file
try: read()
except: pass
how can I let it to read all data from file
thx.