Last active
December 4, 2019 21:46
-
-
Save sodonnell/2ab75ddf2ec87d57cc3ca55e3c075451 to your computer and use it in GitHub Desktop.
Basic YAML Parsing in Python
This file contains 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
language: python | |
python: 3.6 | |
script: | |
- python3 feed.py -u https://phys.org/rss-feed/ | |
- python3 feed.py -u https://hackaday.com/blog/feed/ | |
- python3 feed.py -u https://www.wired.com/feed/rss |
This file contains 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
#!/usr/bin/env python3 | |
import yaml | |
# "unsafe" load of untrusted data | |
#mydata = yaml.load(open("test.yml"), Loader=yaml.FullLoader) | |
# "safe" load of untrusted data | |
mydata = yaml.safe_load(open("test.yml")) | |
# print the entire dictionary | |
print(mydata) | |
# print a specific dictionary node | |
print(mydata['language']) | |
# print a specific dictionary sub-node | |
print(mydata['script'][2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment