-3

この文字列をフォーマットする必要があります。これらは、JSON 配列/オブジェクトの 6 つのレコードにすぎません。すべてを削除するには、Python コードを記述する必要があります" ,。1 行に実際のデータのみを表示したい。

誰かがコードを手伝ってくれますか?これには締め切りがあります....助けてください..

{"status": "ok", "items": [{"1": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "", "Work_Phone": "", "Name_Part": ["PATIENT", "TEST"], "Residence_Phone": "416-", "Mailing_City": "Toronto", "Mailing_Postal_OR_Zip_Code": "", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "", "Cell_Phone": null, "Residential_City": "Toronto", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}, "3": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "", "Work_Phone": "", "Name_Part": ["WOLFIE", "HOWLETT"], "Residence_Phone": "416-", "Mailing_City": "Toronto", "Mailing_Postal_OR_Zip_Code": "", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "", "Cell_Phone": null, "Residential_City": "Toronto", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}, "2": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "18 Yonge St", "Work_Phone": "", "Name_Part": ["Steve", "TEST"], "Residence_Phone": "416-555-5555", "Mailing_City": "Toronto", "Mailing_Postal_OR_Zip_Code": "", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "18 Yonge St", "Cell_Phone": null, "Residential_City": "Toronto", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}, "5": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "", "Work_Phone": "", "Name_Part": ["BUTTERS", "STOTCH"], "Residence_Phone": "416-", "Mailing_City": "Toronto", "Mailing_Postal_OR_Zip_Code": "", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "", "Cell_Phone": null, "Residential_City": "Toronto", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}, "4": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "91041", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "1 Manhattan Ave.", "Work_Phone": "", "Name_Part": ["SUE", "STORM"], "Residence_Phone": "416-555-5556", "Mailing_City": "Star City", "Mailing_Postal_OR_Zip_Code": "91041", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "1 Manhattan Ave.", "Cell_Phone": null, "Residential_City": "Star City", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}, "6": {"Work_Phone_Extension": null, "Residential_Postal_OR_Zip_Code": "", "Residential_Street_Address_line_2": "", "Residential_Street_Address_line_1": "1 Rural Rd E", "Work_Phone": "", "Name_Part": ["CLARK", "KENT"], "Residence_Phone": "416-606-0001", "Mailing_City": "Smallville", "Mailing_Postal_OR_Zip_Code": "", "Mailing_Street_Address_line_2": "", "Mailing_Street_Address_line_1": "1 Rural Rd E", "Cell_Phone": null, "Residential_City": "Smallville", "Residential_Country_AND_Province_OR_State": "CA_ON", "Mailing_Country_AND_Province_OR_State": "CA_ON"}}]}
4

1 に答える 1

0
import json
l_dict = json.loads(long_string)

次に、辞書があり、必要に応じてそれをフォーマット/反復できます。

In [192]: l_dict
Out[192]: 
{u'items': [{u'1': {u'Cell_Phone': None,
    u'Mailing_City': u'Toronto',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'',
    u'Mailing_Street_Address_line_1': u'',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'PATIENT', u'TEST'],
    u'Residence_Phone': u'416-',
    u'Residential_City': u'Toronto',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'',
    u'Residential_Street_Address_line_1': u'',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None},
   u'2': {u'Cell_Phone': None,
    u'Mailing_City': u'Toronto',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'',
    u'Mailing_Street_Address_line_1': u'18 Yonge St',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'Steve', u'TEST'],
    u'Residence_Phone': u'416-555-5555',
    u'Residential_City': u'Toronto',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'',
    u'Residential_Street_Address_line_1': u'18 Yonge St',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None},
   u'3': {u'Cell_Phone': None,
    u'Mailing_City': u'Toronto',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'',
    u'Mailing_Street_Address_line_1': u'',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'WOLFIE', u'HOWLETT'],
    u'Residence_Phone': u'416-',
    u'Residential_City': u'Toronto',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'',
    u'Residential_Street_Address_line_1': u'',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None},
   u'4': {u'Cell_Phone': None,
    u'Mailing_City': u'Star City',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'91041',
    u'Mailing_Street_Address_line_1': u'1 Manhattan Ave.',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'SUE', u'STORM'],
    u'Residence_Phone': u'416-555-5556',
    u'Residential_City': u'Star City',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'91041',
    u'Residential_Street_Address_line_1': u'1 Manhattan Ave.',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None},
   u'5': {u'Cell_Phone': None,
    u'Mailing_City': u'Toronto',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'',
    u'Mailing_Street_Address_line_1': u'',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'BUTTERS', u'STOTCH'],
    u'Residence_Phone': u'416-',
    u'Residential_City': u'Toronto',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'',
    u'Residential_Street_Address_line_1': u'',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None},
   u'6': {u'Cell_Phone': None,
    u'Mailing_City': u'Smallville',
    u'Mailing_Country_AND_Province_OR_State': u'CA_ON',
    u'Mailing_Postal_OR_Zip_Code': u'',
    u'Mailing_Street_Address_line_1': u'1 Rural Rd E',
    u'Mailing_Street_Address_line_2': u'',
    u'Name_Part': [u'CLARK', u'KENT'],
    u'Residence_Phone': u'416-606-0001',
    u'Residential_City': u'Smallville',
    u'Residential_Country_AND_Province_OR_State': u'CA_ON',
    u'Residential_Postal_OR_Zip_Code': u'',
    u'Residential_Street_Address_line_1': u'1 Rural Rd E',
    u'Residential_Street_Address_line_2': u'',
    u'Work_Phone': u'',
    u'Work_Phone_Extension': None}}],
 u'status': u'ok'}
于 2013-02-06T22:21:54.467 に答える