I have a python code that outputs json
import json
from faker import Faker
import random
from random import randint
import subprocess
fake = Faker('en_US')
for _ in range(1):
sms = {
"name": fake.name(),
"email": fake.email(),
"location": "usa"
}
with open('abc.json', 'w') as outfile:
json.dump(sms, outfile)
print(sms)
subprocess:
x=subprocess.Popen([" python"," first.py"],shell=True, stdout=subprocess.PIPE)
output = x.communicate()
print(output)
output I am getting :
(b'{\n "name": "elmoroy",\n "email":"ssbyt@gmail.com"}\n', None)
output I need :
{
"name": "elmoroy",
"email":"ssbyt@gmail.com
}
If I call output["name"]
it should return elmoroy
.