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 254 views
1 answer 258 views
1 answer 314 views
1 answer 345 views
1 answer 320 views
1 answer 330 views
...