1#first file
lista_users = []
print(‘lets create your data, and then store into a file json’)
while True:
store_data = {
'name': '',
'gmail':'',
'dni': '',
}
lista_users.append(store_data)
name = input('name:')
store_data['name'] = name
if name == 'q':
break
gmail = input('gmail:')
store_data['gmail'] = gmail
dni= input('dni:')
store_data['dni'] = dni
#2 file
from store_user_dictionaries import lista_users as usersData
from pathlib import Path
import json
def store_data():
for k in usersData:
path = Path(‘data_users.json’)
content = json.dumps(k,indent=4)
path.write_text(content)
def show_the_data():
path = Path('data_users.json')
content = path.read_text()
loads = json.loads(content)
for k,v in loads.items():
print(f"These are the results of your data:n {k}")
store_data()
show_the_data()
3#the results of my file json.
{
“name”: “q”,
“gmail”: “”,
“dni”: “”
}
I’m begginer in python and programming, I do not understand why the data of my users_list is not imported correctly, the final result is not as expected, I do not understand it, in my final result I should see 3 different users with their respective data.
Jose Antonio Camacho Morales is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.