Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
json.load() in Python 3
#2
try (using f-string (if your python 3.6 or newer)):
for id in id_list:
    with open(f'location{id}') as fp:
        data = json.load(fp)
if using python 3 older than 3.6 use:
for id in id_list:
    with open(f'location{}'.format(id)) as fp:
        data = json.load(fp)
FYI: please use 4 space indentation
Reply


Messages In This Thread
json.load() in Python 3 - by jazmad - Dec-31-2018, 09:36 PM
RE: json.load() in Python 3 - by Larz60+ - Dec-31-2018, 11:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Failed attempts to load Microsoft Appstore Python DLLs piyushd 0 447 Oct-31-2023, 10:43 AM
Last Post: piyushd
  JSON Dump and JSON Load foxholenoob 8 1,139 Oct-12-2023, 07:21 AM
Last Post: foxholenoob
  Python Split json into separate json based on node value CzarR 1 5,641 Jul-08-2022, 07:55 PM
Last Post: Larz60+
  How to load log.txt directly into python codes? sparkt 6 3,000 Aug-21-2020, 03:51 PM
Last Post: sparkt
  Load table from Oracle to MYSQL using python himupant94 0 1,661 May-12-2020, 04:50 PM
Last Post: himupant94
  Python - help with getting JSON from one DB and load to another DB qIekm 4 3,281 Apr-16-2020, 07:07 AM
Last Post: qIekm
  difficulties to chage json data structure using json module in python Sibdar 1 2,098 Apr-03-2020, 06:47 PM
Last Post: micseydel
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,913 Dec-11-2019, 07:50 AM
Last Post: parsley
  python and load balancer pythonFresher 1 2,283 Jul-18-2019, 07:23 AM
Last Post: pythonFresher
  Load JSON file data into mongodb using pymongo klllmmm 1 11,883 Jun-28-2019, 12:47 AM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020