File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ 文章名稱:Python dict to json 如何轉換?提供範例給你參考
2+
3+ 文章連結:https://shareboxnow.com/python-dict-to-json/
4+
5+ 程式碼位置:https://github.com/MarkwwLiu/PythonBasicTeaching/tree/master/Python/DictToJson
6+
7+ 執行方式: ` python3 dict_to_json.py `
8+
Original file line number Diff line number Diff line change 1+ import json
2+ import os
3+ from datetime import datetime
4+ # 範例的字典檔案
5+ example_dict = {
6+ "123" : "tttt" ,
7+ "1123" : ["123" , "fffff" ],
8+ "fffff" : "awinni12344%%^^" ,
9+ "kkkkffff" : "你好啊!!"
10+ }
11+
12+
13+ def main (save_json_path , save_json_name , dataDict ):
14+ """
15+ :param save_json_path: 你要儲存json的位置
16+ :param save_json_name: 你要將字典存入到json的檔案名稱叫做什麼
17+ :param dataDict: dict資料
18+ """
19+ now_time = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
20+
21+ with open (save_json_path + save_json_name + ".json" , 'w' ) as json_file :
22+ json .dump (dataDict , json_file )
23+ print ("[%s] Json 檔案儲存至: %s" % (now_time , save_json_path + save_json_name + ".json" ))
24+
25+
26+ if __name__ == '__main__' :
27+ main (save_json_path = os .getcwd () + '/' , save_json_name = "test" , dataDict = example_dict )
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ Python基本教學,詳細資訊請查看我的部落格:https://shareboxnow.
3939
4040程式碼位置:https://github.com/MarkwwLiu/PythonBasicTeaching/tree/master/GoogleDrive/UploadFile
4141
42+ #
43+ 文章名稱:python上傳檔案到Google Drive 指定的資料夾,程式碼大公開,詳細解說
44+
45+ 文章連結:https://shareboxnow.com/python-google-drive-2/
46+
47+ 程式碼位置:https://github.com/MarkwwLiu/PythonBasicTeaching/tree/master/GoogleDrive/UploadFileSpecifiedFolder
48+
4249---
4350# Python
4451
You can’t perform that action at this time.
0 commit comments