From 8800a0f19ba9c66d8d17c3c9282fbb90a669d04d Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 11 Mar 2021 10:49:27 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20with=20=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Json2Yaml.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Json2Yaml.py b/tests/Json2Yaml.py index b16b4a7..b13090a 100644 --- a/tests/Json2Yaml.py +++ b/tests/Json2Yaml.py @@ -2,6 +2,7 @@ # Author - HoneyMoose (https://www.ossez.com) import json + import ruamel.yaml as yaml json_filename = 'resources/black_rock_test.json' @@ -18,6 +19,5 @@ with open(json_filename) as json_file: json_file.close() # Write to YAML -yaml_file = open(yaml_filename, 'w+') -yaml.dump(data, yaml_file, allow_unicode=True) -yaml_file.close() +with open(yaml_filename, 'w') as yaml_file: + yaml.dump(data, yaml_file, allow_unicode=True) From b0ee52147006b662233d37dc4e5d07e91ddb3e81 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 11 Mar 2021 10:51:43 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20with=20=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E5=86=99=E5=85=A5=20yaml=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/FileWith.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/FileWith.py b/tests/FileWith.py index b989bb5..221189c 100644 --- a/tests/FileWith.py +++ b/tests/FileWith.py @@ -3,7 +3,10 @@ import json +import ruamel.yaml as yaml + json_filename = 'resources/honeymoose_test.json' +yaml_filename = 'resources/honeymoose_test.yaml' # Read and process JSON with open(json_filename) as json_file: @@ -15,3 +18,7 @@ with open(json_filename) as json_file: print(str(label_id)) print(json_file.closed) + +# Using with write to YAML +with open(yaml_filename, 'w') as yaml_file: + yaml.dump(data, yaml_file, allow_unicode=True) From b368ab17d94f871ba4e2abc2140a546b8067846a Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 11 Mar 2021 10:53:44 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _sidebar.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_sidebar.md b/_sidebar.md index e2fa30e..7693cac 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -9,8 +9,8 @@ - [第一个 Hello World 程序](docs/course/foundation/04_hello_world.md) - [语言基础](docs/course/foundation/05_language_fundamentals.md) -- 其他小工具 - - [JWT](jwt/README.md) +- 附录索引 + - [Python 用例索引](docs/appendix/01_use_cases.md) - [MessagePack](message-pack/index.md) - [Protocol Buffers](protocol-buffers/index.md)