Basic Python Learning--Dict

sys_conf = {}
sys_conf["type"] = "charts"
sys_conf["client"] = "GWM"
print(sys_conf)

# sys_conf["conf"] error
conf = sys_conf.get("conf", "no conf key in dict")
print(conf)  # !
conf = sys_conf.get("conf")
print(conf)
print("test point1")

if not sys_conf.get("conf"):
    sys_conf["conf"] = {}
    sys_conf["conf"]["sensors"] = {"typeList": ["UFS", "PAS"]}
print(sys_conf)

print("test".center(20, "*"))
for k, v in sys_conf.items():
    print(k, v)
print("test".center(20, "*"))
for k in sys_conf.keys():
    print(k)

print("test".center(20, "*"))
for v in sys_conf.values():
    print(v)

print("test".center(20, "*"))
for k, v in sys_conf.items():
    if k == "conf":
        print(sys_conf[k]['sensors']['typeList'])

del sys_conf["type"]  # attention
print(sys_conf)


car = {
    'link': "www.cars.net",
    'type': "battery car",
    'brand': "tesla",
    'mode': "model S",
    'color': "red",
    'recharge mileage': '500kms',
    'price': {
        "Area": "China",
        "Net": 600000,
        "TaxRate": {
            "ImportTariffs": 0.1,  #
            "ValueAdded": 0.08,
            "Sale": 0.02
        },
        "Subside": 20000,
        "FinalPrice": 700000
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值