I have this sample yaml,
data:
- name: data1
sourceType: aws
sourceSpecifier: acme/data123.zip
- name: data2
sourceType: aws
sourceSpecifier: acme/data234.zip
- name: data3
sourceType: webdav
sourceSpecifier: acme/data334.zip
sources:
- type: aws
baseUrl: example.s3.us-east-2.amazonaws.com
- type: webdav
baseUrl: https://internal-acme.example.com/
Please help to share the python script that will give an output:
example.s3.us-east-2.amazonaws.com/acme/data123.zip
https://internal-acme.example.com/acme/data334.zip
If your file is called "homework1.yaml"
, then load the data using
import yaml
data = yaml.safe_loads("homework1.yaml")
data
should be a dict containing the keys "data"
and "sources"
. Of these, data["data"]
is a list containing three dictionaries, and data["sources"]
is a list containing two dictionaries. All you have to do left is to match elements. Since you haven't specified in which type of data structure to save the match, that's all we can do for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.