Merge pull request #19 from cwiki-us-docs/naming_rules

Naming rules
This commit is contained in:
YuCheng Hu 2021-03-11 10:41:50 -05:00 committed by GitHub
commit eb2175785a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 0 deletions

View File

@ -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 关键字的使用进行了一些解答。 |

17
tests/FileWith.py Normal file
View File

@ -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)

23
tests/Json2Yaml.py Normal file
View File

@ -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()

View File

@ -2,6 +2,7 @@
# Author - https://www.ossez.com
import keyword
import json
print(keyword.kwlist)
print(len(keyword.kwlist))

View File

@ -0,0 +1,10 @@
[
{
"label_id": 603,
"user_name": "YUCHENG-L1"
},
{
"label_id": 604,
"user_name": "YUCHENG-L2"
}
]

View File

@ -0,0 +1,10 @@
[
{
"label_id": 603,
"user_name": "YUCHENG-L1"
},
{
"label_id": 604,
"user_name": "YUCHENG-L2"
}
]