From ea0f1cda56b27bfd2133f4930ddba8a3e4fedc5e Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Wed, 10 Mar 2021 16:04:12 -0500 Subject: [PATCH 1/5] =?UTF-8?q?=E8=B7=9F=E8=A1=80=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=E6=98=BE=E7=A4=BA=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Keywords.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Keywords.py b/tests/Keywords.py index 4c23962..75f556f 100644 --- a/tests/Keywords.py +++ b/tests/Keywords.py @@ -2,6 +2,7 @@ # Author - https://www.ossez.com import keyword +import json print(keyword.kwlist) print(len(keyword.kwlist)) From 75a705df05d97e608606250d46a73b3970aea8b5 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Wed, 10 Mar 2021 16:08:02 -0500 Subject: [PATCH 2/5] =?UTF-8?q?Json2Yaml=20=E4=BD=BF=E7=94=A8=20Python=20?= =?UTF-8?q?=E5=B0=86=20Json=20=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=20yaml=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Json2Yaml.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/Json2Yaml.py diff --git a/tests/Json2Yaml.py b/tests/Json2Yaml.py new file mode 100644 index 0000000..b16b4a7 --- /dev/null +++ b/tests/Json2Yaml.py @@ -0,0 +1,23 @@ +# Python script to Read file from JSON and convert to YAML +# Author - HoneyMoose (https://www.ossez.com) + +import json +import ruamel.yaml as yaml + +json_filename = 'resources/black_rock_test.json' +yaml_filename = 'resources/black_rock_test.yaml' + +# Read and process JSON +with open(json_filename) as json_file: + data = json.load(json_file) + print(type(data)) + + for data_dict in data: + label_id = data_dict['label_id'] + print(str(label_id)) +json_file.close() + +# Write to YAML +yaml_file = open(yaml_filename, 'w+') +yaml.dump(data, yaml_file, allow_unicode=True) +yaml_file.close() From 9fdf9e24b80cd757cde068ae15299196e0829818 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Wed, 10 Mar 2021 16:51:43 -0500 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20JSON=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/resources/black_rock_test.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/resources/black_rock_test.json diff --git a/tests/resources/black_rock_test.json b/tests/resources/black_rock_test.json new file mode 100644 index 0000000..b608e34 --- /dev/null +++ b/tests/resources/black_rock_test.json @@ -0,0 +1,10 @@ +[ + { + "label_id": 603, + "user_name": "YUCHENG-L1" + }, + { + "label_id": 604, + "user_name": "YUCHENG-L2" + } +] \ No newline at end of file From 2c5c8229c756d0418a6555f5e5c70e947351b1e0 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 11 Mar 2021 10:40:37 -0500 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=92=8C=20with=20=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/appendix/01_use_cases.md | 16 ++++++++++++++++ tests/FileWith.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/appendix/01_use_cases.md create mode 100644 tests/FileWith.py diff --git a/docs/appendix/01_use_cases.md b/docs/appendix/01_use_cases.md new file mode 100644 index 0000000..c117f5b --- /dev/null +++ b/docs/appendix/01_use_cases.md @@ -0,0 +1,16 @@ +# Python 用例索引 +为了方便大家索引内容,我们将我们这套教程中的相关使用用例通过索引的方式列出来了。 + +因为 MD 文件格式的局限性,我们没有办法在这里帮助大家进行一一解答和讨论,所以我们将解答和用例放到了 [WWW.OSSEZ.COM](https://www.ossez.com) 平台下 Python 分类中。 + +请访问: https://www.ossez.com/c/open-source/python/14 参与讨论,我会在这里等着大家。 + +## 索引链接 +请通过索引的链接快速参与讨论了解更多详细的内容。 + +### 语言基础 +针对语言的基础,请访问下面的的链接中的内容。 + +| 文章标题 | 简要介绍 | +|---|---| +| [Python With 关键字和语句](https://www.ossez.com/t/python-with/13387) | 针对 with 关键字的使用进行了一些解答。 | diff --git a/tests/FileWith.py b/tests/FileWith.py new file mode 100644 index 0000000..b989bb5 --- /dev/null +++ b/tests/FileWith.py @@ -0,0 +1,17 @@ +# Python script to Read file from JSON and convert to YAML +# Author - HoneyMoose (https://www.ossez.com) + +import json + +json_filename = 'resources/honeymoose_test.json' + +# Read and process JSON +with open(json_filename) as json_file: + data = json.load(json_file) + print(type(data)) + + for data_dict in data: + label_id = data_dict['label_id'] + print(str(label_id)) + +print(json_file.closed) From ff5bc311749c416b7971c0a3100fdad7a624d301 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 11 Mar 2021 10:41:12 -0500 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=94=A8=E4=BA=8E=E6=B5=8B=E8=AF=95=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/resources/honeymoose_test.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/resources/honeymoose_test.json diff --git a/tests/resources/honeymoose_test.json b/tests/resources/honeymoose_test.json new file mode 100644 index 0000000..b608e34 --- /dev/null +++ b/tests/resources/honeymoose_test.json @@ -0,0 +1,10 @@ +[ + { + "label_id": 603, + "user_name": "YUCHENG-L1" + }, + { + "label_id": 604, + "user_name": "YUCHENG-L2" + } +] \ No newline at end of file