# documents.yaml name:TheSetofGauntlets'Pauraegen' description:> A set of handgear with sparks that crackle across its knuckleguards. --- name:TheSetofGauntlets'Paurnen' description:> A set of gauntlets that gives off a foul, acrid odour yet remains untarnished. --- name:TheSetofGauntlets'Paurnimmen' description:> Asetofhandgear,freezingwithunnaturalcold.
yaml.load_all 方法会生成一个迭代器
>>> withopen("documents.yaml", mode = "r") as f: ... docs = f.read() ... >>> for doc in yaml.load_all(docs, Loader=yaml.FullLoader): ... print(doc) ... {'name': "The Set of Gauntlets 'Pauraegen'", 'description': 'A set of handgear with sparks that crackle across its knuckleguards.\n'} {'name': "The Set of Gauntlets 'Paurnen'", 'description': 'A set of gauntlets that gives off a foul, acrid odour yet remains untarnished.\n'} {'name': "The Set of Gauntlets 'Paurnimmen'", 'description': 'A set of handgear, freezing with unnatural cold.\n'}