import netifaces
import netaddr
import yaml
class Ethernet(yaml.YAMLObject):
def __init__(self, addresses, gateway4, mtu, nameservers):
self.nameservers = nameservers
self.mtu = mtu
self.gateway4 = gateway4
self.addresses = addresses
我正在尝试将此类写入 yum 文件:
with open("/home/netplan.yaml", "w") as file:
yaml.dump(document, file, default_flow_style=False)
我得到这个结果:
!!python/object:__main__.Netplan
network: !!python/object:__main__.Network
ethernets:
docker0: !!python/object:__main__.Ethernet
addresses:
- 172.26.0.1/16
gateway4: 1.1.1.1
mtu: 9000
如何删除所有元信息,例如 !!python/object: main。 来自 yaml 文件?