Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Last active February 16, 2021 00:52
Show Gist options
  • Save thanakijwanavit/241c4cc443f39ea096820f5dfb84017d to your computer and use it in GitHub Desktop.
Save thanakijwanavit/241c4cc443f39ea096820f5dfb84017d to your computer and use it in GitHub Desktop.
convert dict to yaml and vise versa in python
import yaml
print(yaml.dump({'hello':'world',
'stacked': {'hello1':'world1'}}))
$schema: http://json-schema.org/schema#
properties:
cprcode:
type: integer
iprcode:
type: integer
oprCode:
type: string
required:
- cprcode
- iprcode
- oprCode
type: object
import yaml
yaml.load('hello: world\nstacked:\n hello1: world1\n', , Loader=yaml.FullLoader)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment