first commit
This commit is contained in:
parent
57498be685
commit
0efd9bde06
21
readerFromJSON.py
Normal file
21
readerFromJSON.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import json
|
||||||
|
from pprint import pprint
|
||||||
|
from random import choice
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
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)
|
||||||
|
return out_string
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if argv[1:]:
|
||||||
|
print(generateFromJson(str(argv[1])))
|
||||||
|
else:
|
||||||
|
print('Usage:', argv[0], 'something_antani.json')
|
Loading…
Reference in New Issue
Block a user