https://github.com/zhanghan114/collections/tree/master 把老师讲的整理一下放到了github上面,多多支持bobby
2018-02-07
from collections import ChainMap
ImportError: cannot import name ChainMap
ImportError: cannot import name ChainMap
2018-01-28
#conding=utf-8
from collections import namedtuple
User = namedtuple("USER", ["name", "age", "city", "height"])
user = User(name="陳書劍", age=21, city="北京", height="175")
print(user.name, user.age, user.city, user.height)
from collections import namedtuple
User = namedtuple("USER", ["name", "age", "city", "height"])
user = User(name="陳書劍", age=21, city="北京", height="175")
print(user.name, user.age, user.city, user.height)
2018-01-25
from collections import namedtuple
User = namedtuple("USER", ["name", "age", "height"]
user = User(name="書劍", age=10, height=189)
print(user.name, user.age, user.height)
User = namedtuple("USER", ["name", "age", "height"]
user = User(name="書劍", age=10, height=189)
print(user.name, user.age, user.height)
2018-01-25
#conding=utf-8
from collections import deque
test = deque()
test.append("10")
test.appendleft("20")
# test.clear()
test1 = test.copy()
a = test.count(1)
test.extend(test1)
print(a)
print(test1, id(test1))
print(test, id(test))
from collections import deque
test = deque()
test.append("10")
test.appendleft("20")
# test.clear()
test1 = test.copy()
a = test.count(1)
test.extend(test1)
print(a)
print(test1, id(test1))
print(test, id(test))
2018-01-25
def test():
return {
"name": "书剑",
"age": 10
}
num_test = defaultdict(test)
num_test["user"]
return {
"name": "书剑",
"age": 10
}
num_test = defaultdict(test)
num_test["user"]
2018-01-25