-
[python] tuplesPrograming/Python 2019. 4. 26. 15:19
튜플은 엘리먼트 변경이 불가능한 값들의 조합입니다. 형식은 다음과 같이 괄호에 엘리멘트를 포함시키면 됩니다.
이때, 엘리먼트 끝에 콤마(trailing comma)가 있는 없는 경우 스트링으로 사용이 가능합니다.
---
Tuples are immutable sequences of arbitrary objects. They are indexed by integers greater
than zero. Tuples are hashable, which means we can sort lists of them and they can be used
as keys to dictionaries. Syntactically, tuples are just a comma-separated sequence of values;
however, it is common practice to enclose them in parentheses:
tpl= ('a', 'b', 'c')
It is important to remember to use a trailing comma when creating a tuple with one
element, for example:
t = ('a',)
Without the trailing comma, this would be interpreted as a string.'Programing > Python' 카테고리의 다른 글
print each element in a list (0) 2019.06.06 [python] string center (0) 2019.05.09 [django] Error: 'static', expected 'endblock'. Did you forget to register or load this tag (0) 2019.04.15 [django] template 상속 (0) 2019.04.11 [django] 404 page 변경하기 (0) 2019.04.10