How I can dump a Python tuple in JSON format?

PythonServer Side ProgrammingProgrammingJSON

JSON stands for Javascript object notation. It is a lightweight, language-independent data interchange format. Python library has json module that provides functions for json encoding and decoding.

The dumps() function converts a Python object to JSON format

>>> T1=(12, "Ravi", "B.Com FY", 78.50)
>>> import json
>>> str1=json.dumps(T1)
>>> str1
'[12, "Ravi", "B.Com FY", 78.5]'


raja
Published on 09-Feb-2018 00:30:10
Advertisements