728x90

νŠœν”Œμ€ μ–΄λ–»κ²Œ λ§Œλ“€κΉŒ?

t1 = ()
t2 = (1,)
t3 = (1, 2, 3)
t4 = 1, 2, 3
t5 = ('a', 'b', ('ab', 'cd'))
  • t2 = (1,)처럼 단지 1개의 μš”μ†Œλ§Œμ„ κ°€μ§ˆ λ•ŒλŠ” μš”μ†Œ 뒀에 μ‰Όν‘œ(,)λ₯Ό λ°˜λ“œμ‹œ λΆ™μ—¬μ•Ό ν•œλ‹€.
  • t4 = 1, 2, 3처럼 μ†Œκ΄„ν˜Έ(())λ₯Ό μƒλž΅ν•΄λ„ λœλ‹€.
  • νŠœν”Œκ³Ό 리슀트의 κ°€μž₯ 큰 μ°¨μ΄λŠ” μš”μ†Ÿκ°’μ„ λ³€ν™”μ‹œν‚¬ 수 μžˆλŠ”μ§€μ˜ 여뢀이닀. 즉, 리슀트의 μš”μ†Ÿκ°’μ€ λ³€ν™”κ°€ κ°€λŠ₯ν•˜κ³  νŠœν”Œμ˜ μš”μ†Ÿκ°’μ€ λ³€ν™”κ°€ λΆˆκ°€λŠ₯ν•˜λ‹€. 
  • μš”μ†Ÿκ°’μ„ μ‚­μ œν•˜κ±°λ‚˜ λ³€κ²½ν•˜λ €κ³  ν•˜λ©΄ 였λ₯˜ λ°œμƒ

νŠœν”Œ 닀루기

01. μΈλ±μ‹±ν•˜κΈ°

>>> t1 = (1, 2, 'a', 'b')
>>> t1[0]
1
>>> t1[3]
'b'

02. μŠ¬λΌμ΄μ‹±ν•˜κΈ°

>>> t1 = (1, 2, 'a', 'b')
>>> t1[1:]
(2, 'a', 'b')

03. νŠœν”Œ λ”ν•˜κΈ°

>>> t1 = (1, 2, 'a', 'b')
>>> t2 = (3, 4)
>>> t3 = t1 + t2
>>> t3
(1, 2, 'a', 'b', 3, 4)

04. νŠœν”Œ κ³±ν•˜κΈ°

>>> t2 = (3, 4)
>>> t3 = t2 * 3
>>> t3
(3, 4, 3, 4, 3, 4)

05. νŠœν”Œ 길이 κ΅¬ν•˜κΈ°

>>> t1 = (1, 2, 'a', 'b')
>>> len(t1)
4

+ Recent posts