Created
January 21, 2023 20:44
-
-
Save Merwanski/045a61c6a76762ee8d87cc2dbbb82bcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
## MAKE YAML | |
#!/usr/bin/env python | |
import yaml | |
import numpy as np | |
a = np.matrix('1 2; 3 4') | |
z = 'hello world' | |
data = dict( | |
array = str(a), | |
string = z | |
) | |
with open('data.yml', 'w') as outfile: | |
yaml.dump(data, outfile, default_flow_style=False) | |
######################################################################## | |
## READ YAML | |
#!/usr/bin/env python | |
import yaml | |
with open('data.yml') as info: | |
dict = yaml.load(info) | |
print(dict) | |
print(dict.z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment