struct trong python

Solutions on MaxInterview for struct trong python by the best coders in the world

showing results for - "struct trong python"
Lucia
16 Jan 2016
1from collections import namedtuple
2
3Something = namedtuple("Something", ["x", "y"])
4p1 = Point(1, 2)
5print(p1)
6# gọi attribute
7print(p1.x, p1.y)
8# gọi theo chỉ số
9print(p1[0], p1[1])
10
11# nếu có ý định gán thì error ngay lập tức
12p1.x = 2  # lỗi AttributeError: can't set attribute
13
similar questions
queries leading to this page
struct trong python