How to convert from a string to JSON string in Python

1 Answer

0 votes
import json

s = "python"

jsn = json.dumps(s)

print(jsn)

print(jsn[0])
print(jsn[1])
print(jsn[2])
print(jsn[3])

print(type(jsn))
print(type(s))


'''
run:

"python"
"
p
y
t
<class 'str'>
<class 'str'>

'''

 



answered Nov 24, 2018 by avibootz

Related questions

1 answer 255 views
1 answer 259 views
1 answer 315 views
1 answer 346 views
1 answer 320 views
1 answer 331 views
...