User Tools

Site Tools


sidebar_python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sidebar_python [2024/05/10 11:57] – created waltersidebar_python [2024/06/01 15:05] (current) walter
Line 1: Line 1:
-====== Load, Save, Print JSON-File ======+====== Übersicht Python ======
  
-<code python> +  * [[python_json|JSON Handling]] 
-import json +  * [[python_sort|Sortieren von list/dictionary]] 
-</code>+  * [[python_terminalsize|Terminal-Breite/Höhe bestimmen]] 
 +  * [[python_qtableview|QTableview]]
  
-**LOAD** 
- 
-<code python> 
-json_data = '[{"ID":10,"Name":"Pankaj","Role":"CEO"},{"ID":20,"Name":"David Lee","Role":"Editor"}]' 
-json_object = json.loads(json_data) 
- 
-with open('Cars.json', 'r') as json_file: 
-    json_object = json.load(json_file) 
-</code> 
- 
-**SAVE** 
- 
-<code python> 
-with open('data.json', 'w', encoding='utf-8') as f: 
-    json.dump(data, f, ensure_ascii=False, indent=4) 
-</code> 
- 
-**PRINT** 
- 
-<code python> 
-print(json_object) 
-print(json.dumps(json_object)) 
-print(json.dumps(json_object, indent=1))  # pretty print 
-</code> 
sidebar_python.1715342233.txt.gz · Last modified: 2024/05/10 11:57 by walter