commit
cef94b0cef
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue