사용자 도구

사이트 도구


python:built-in

python의 data type을 알아 볼까요

Built-In type

Boolean

  • bool

Numeric

  • int
  • float
  • complex

String

  • str

Sequence

  • list
  • tuple
  • range

Set

  • set
  • frozenset

Mapping

  • dict

Iterator

  • ___iter__()
  • ___next___()

Hello World!

기초자료형
# numeric
a = -1
b = 1.0
print(f"{type(a)} {a}")
print(f"{type(b)} {b}")
c = complex(101, 2)
print(f"{type(c)} {c}")
 
# string
s1 = """0123456789-abcd"""
print(f"{type(s1)} {s1} {s1[0::5]}")
 
# boolean
print(f"{type(False)} {True} {1 != 1}")
 
# List
kk = ['k', 'asdf', "김재성"]
print(f"{type(kk)} {kk}")
 
# Tuple
kk = ('k', 'asdf', "김재성")
print(f"{type(kk)} {kk}")
 
# Dictionary
kk = {'name':'maro', 'nation':'Korea'}
print(f"{type(kk)} {kk}, len: {len(kk)}")

output

<class 'int'> -1
<class 'float'> 1.0
<class 'complex'> (101+2j)
<class 'str'> 0123456789-abcd 05-
<class 'bool'> True False
<class 'list'> ['k', 'asdf', '김재성']
<class 'tuple'> ('k', 'asdf', '김재성')
<class 'dict'> {'name': 'maro', 'nation': 'Korea'}, len: 2
python/built-in.txt · 마지막으로 수정됨: 2025/04/15 10:05 저자 127.0.0.1