According to the YAML spec, iso8601 dates with timezones should be recognised。然而,在试图用他们3.10 PyYAML解析(在Windows 7的ActivePython 2.7.2.5)我得到天真日期: In [7]: yaml.load("2001-12-14t21:59:43.10-05:00")
Out[7]:
对象的属性,我可以使用YAML转储蟒蛇对象的层次,所以: import yaml
class C():
def __init__(self, x, y):
self.x = x
self.y = y
class D():
def __init__(self, c, d):
self.c = c
self.d = d
d
我使用PyYaml从我自己的python对象创建Yaml文档。 例如我的对象: class MyObj(object):
name = "boby"
age = 34
变为: boby:
age: 34
到目前为止好。 但我还没有发现一种以编程方式添加注释到生产YAML所以它看起来像: boby: # this is the name
age: 3