补充一点,老师说 tuple 不可变不是绝对的,比如这种 tuple (1, [1, 2]),那么 tuple 可以作为 dict 的 key 也不是绝对的,同上 tuple (1, [1, 2])
2018-06-29
title = ['a', 'b', 'c', 'b', 'c', 'c']
value_count = {}.fromkeys(title, 0)
for a in title:
value_count[a] += 1
print value_count
value_count = {}.fromkeys(title, 0)
for a in title:
value_count[a] += 1
print value_count
2018-04-26
user_dict = {
"name":"bobby",
"age":29,
"height":175,
"edu": "master"
}
user = User._make(user_dict)
的结果是:
age name height edu
"name":"bobby",
"age":29,
"height":175,
"edu": "master"
}
user = User._make(user_dict)
的结果是:
age name height edu
2018-04-19
py3.6 dict 其实只是 insertion ordered
ref: https://stackoverflow.com/a/39980744/6266737
ref: https://stackoverflow.com/a/39980744/6266737
2018-04-15