#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
老师说python3下的dict是有序的,但是我运行python3.5.2下的dict,每次运行出来的dict顺序都是不一样的,是随机的
2018-01-23