List to json Python
Ngày đăng:
24/02/2022
Trả lời:
0
Lượt xem:
58
Use json.dumps() to convert a list to a JSON array in Python. The dumps() function takes a list as an argument and returns a JSON String. json.dumps(obj)Python list to JSON array exampleSimple example code converting given list ["1", "2", "3"] to a JSON array results in the string '["1", "2", "3"]'. For this example, you have to import a JSON module into the project file. import json aList = ["1", "2", "3"] res = json.dumps(aList) print(res) print(type(res))Output: Do comment if you have any doubts and suggestions on this Python JSON and List topic.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical. Share this:
Related |