Browse Source

fixed bug

master
Elray02 4 years ago
parent
commit
edad51c72d
  1. 11
      readerFromJSON.py

11
readerFromJSON.py

@ -1,21 +1,18 @@
import json
from pprint import pprint
from random import choice
from sys import argv
from collections import OrderedDict
def generateFromJson(text):
with open(text) as data_file:
out_list = []
data = json.load(data_file)
for i in data:
out_list.append(choice(data[i]))
out_string = " ".join(out_list)
data = json.load(data_file, object_pairs_hook=OrderedDict)
out_string = " ".join(choice(data[keys])for keys in data)
return out_string
if __name__ == '__main__':
if argv[1:]:
print(generateFromJson(str(argv[1])))
print(generateFromJson(argv[1]))
else:
print('Usage:', argv[0], 'something_antani.json')
Loading…
Cancel
Save