You have to specify a mode to the open() function. In this case I think you’re trying to read the file, so your mode would be "r". Your code should be:
with open(r'path/to/read/','r') as file:
data = json.load(file)
import sys
import os
import json
def JsonRead(str):
with open(str, encoding='utf-8') as f:
data = json.load(f)
return data
new_Data = JsonRead(filePath)
3
Answers
You have to specify a mode to the open() function. In this case I think you’re trying to read the file, so your mode would be "r". Your code should be:
Your code should run now.
Your path should not contain spaces. Please modify the file path.
Generally speaking, the file path is best to be in full English with no spaces and no special characters.
Then import JsonRead in project