Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- item = input('Введите товар: ')
- quantity = input('Введите количество: ')
- price = input('Введите цену: ')
- buyer = input('Введите покупателя: ')
- date = input('Введите дату: ')
- '''
- dict = {'item': item, 'quantity': quantity, 'price': price, 'buyer': buyer, 'date': date}
- print(dict)
- '''
- def write_order_to_json(*args):
- #dict = {}
- dict = {'item': 0, 'quantity': 0, 'price': 0, 'buyer': "", 'date': ""}
- i=0
- #dict2 = {'item': 'товар ', 'quantity': 'кол-во ', 'price': "цена ", 'buyer': 'покупатель ', 'date': 'дата '}
- for k in dict.keys():
- dict[k] = args[i]
- i += 1
- print(dict)
- with open('orders.json', 'w') as f_n:
- json.dump(dict, f_n, sort_keys=True, indent=4)
- with open('orders.json') as f_n:
- print(f_n.read())
- write_order_to_json(item, quantity, price, buyer, date)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement