攝影或3C

Python如何讀取json檔?codebeautify.org 線上瀏覽json檔, with open(targetJson,”r”) as f:     json_str = f.read()  ;   jsn = json.loads(json_str)

看一下2330.txt的結構

targetJson = r”C:\Python\Json\2330.txt”

import json
with open(targetJson,”r”) as f:
  json_str = f.read()
  jsn = json.loads(json_str)
  print(jsn)

 

Visual Studio Code出現找不到指定模組錯誤

需要寫一個settings.json的檔案

import json
targetJson = r”C:\Python\Json\settings.json”

with open(targetJson, “r”) as f:
  print(f,type(f))
  json_str = f.read()
  print(json_str,type(json_str))
  jsonloads = json.loads(json_str)
  print(jsonloads,type(jsonloads))
輸出結果:

settings.json:

{‘python.defaultInterpreterPath’: ‘D:\\myInstallation\\Python310\\python.exe’, ‘files.encoding’: ‘utf8’, ‘terminal.integrated.profiles.windows’: {‘Command Prompts’: {‘path’: [‘${env:windir}\\System32\\cmd.exe’], ‘args’: [], ‘icon’: ‘terminal-cmd’}}, ‘terminal.integrated.defaultProfile.windows’: ‘Command Prompts’, ‘editor.autoIndent’: ‘advanced’}

 

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡