| ν¨μλͺ | μ€λͺ | μμ |
|---|---|---|
print() | μ½μμ μΆλ ₯ | |
input() | μ¬μ©μ μ λ ₯ λ°κΈ° | |
len() | κΈΈμ΄ λ°ν | |
range() | λ°λ³΅ κ°λ₯ν μ«μ λ²μ μμ± | |
list() | 리μ€νΈλ‘ λ³ν | |
map() | κ° μμμ ν¨μ μ μ© | list(map(int, ["1", "2"])) β [1, 2] |
filter() | 쑰건μ λ§μ‘±νλ κ°λ§ νν°λ§ | list(filter(lambda x: x>0, [-1,2,3])) β [2,3] |
zip() | μ¬λ¬ iterable λ³λ ¬ λ¬ΆκΈ° | list(zip([1,2], ['a','b'])) β [(1,'a'),(2,'b')] |
enumerate() | μΈλ±μ€μ κ°μ ννλ‘ λ°ν | list(enumerate(['a','b'])) β [(0,'a'),(1,'b')] |
max() | μ΅λκ° λ°ν | |
min() | μ΅μκ° λ°ν | |
sum() | ν©κ³ λ°ν | |
sorted() | μ λ ¬λ 리μ€νΈ λ°ν | |
abs() | μ λκ° λ°ν | |
int() | μ μνμΌλ‘ λ³ν | |
str() | λ¬Έμμ΄λ‘ λ³ν | |
float() | μ€μνμΌλ‘ λ³ν | |
bool() | λΆλ¦¬μΈκ° λ³ν | |
ord() | λ¬Έμλ₯Ό μμ€ν€μ½λλ‘ λ³ν | ord('A') β 65 |
chr() | μμ€ν€μ½λλ₯Ό λ¬Έμλ‘ λ³ν | chr(65) β 'A' |
divmod() | (λͺ«, λλ¨Έμ§) νν λ°ν | divmod(7, 3) β (2, 1) |
pow() | κ±°λμ κ³± κ³μ° | pow(2, 3) β 8 |
round() | λ°μ¬λ¦Ό | round(3.1415, 2) β 3.14 |
set() | μ§ν© μμ± | set([1,2,2,3]) β {1,2,3} |
dict() | λμ λ리 μμ± | dict(a=1, b=2) β {'a':1, 'b':2} |
tuple() | νν μμ± | tuple([1,2,3]) β (1,2,3) |
type() | κ°μ²΄ νμ λ°ν | |
isinstance() | ν΄λμ€ μΈμ€ν΄μ€ μ¬λΆ νμΈ |
| ν¨μλͺ | μ€λͺ | μμ |
|---|---|---|
all() | λͺ¨λ μ°Έμ΄λ©΄ True | all([1,2,3]) β True |
any() | νλλΌλ μ°Έμ΄λ©΄ True | any([0, 0, 1]) β True |
bin() | 2μ§μ λ¬Έμμ΄ λ°ν | bin(7) β '0b111' |
oct() | 8μ§μ λ¬Έμμ΄ λ°ν | oct(8) β '0o10' |
hex() | 16μ§μ λ¬Έμμ΄ λ°ν | hex(15) β '0xf' |
eval() | λ¬Έμμ΄μ μ½λλ‘ μ€ν | eval("1+2") β 3 |
reversed() | μμ λ°λ³΅μ λ°ν | list(reversed([1,2,3])) β [3,2,1] |
id() | κ°μ²΄ κ³ μ ID λ°ν | null |
globals() / locals() | μ¬λ³Ό ν μ΄λΈ λ°ν | null |
dir() | κ°μ²΄μ μμ±κ³Ό λ©μλ 리μ€νΈ | null |
getattr() | κ°μ²΄μ μμ± λ°ν | null |
setattr() | κ°μ²΄μ μμ± μ€μ | null |
hasattr() | μμ± μ‘΄μ¬ μ¬λΆ νμΈ | null |
delattr() | μμ± μμ | null |
super() | λΆλͺ¨ ν΄λμ€ μ°Έμ‘° | null |
staticmethod() / classmethod() | μ μ /ν΄λμ€ λ©μλ μ μ | null |
| μ ν | μμ£Ό μ¬μ©νλ ν¨μ |
|---|---|
| μ λ ¬/μ°μ μμ | sorted, max, min |
| 리μ€νΈ/λ°°μ΄ μ‘°μ | map, filter, zip, enumerate, list, set, tuple |
| λ¬Έμμ΄ λ¬Έμ | ord, chr, str, int, float |
| 쑰건 κ²μ¬ | all, any, bool, isinstance |
| μν μ°μ° | abs, pow, divmod, round, sum |
| ν΄μ/λμ λ리 | dict, in, getattr, setattr, hasattr |
| λͺ¨λ | μ£Όμ κΈ°λ₯ | μμ |
|---|---|---|
heapq | μ΅μ/μ΅λ ν ꡬν | heapq.heappush() / heapq.heappop() |
collections | μ μ©ν 컨ν μ΄λ ν΄λμ€ | Counter, defaultdict, deque |
itertools | μμ΄/μ‘°ν© λ± λ°λ³΅μ μμ± | permutations, combinations, product |
bisect | μ΄μ§ νμ κΈ°λ° μ½μ /κ²μ | bisect.bisect_left(), bisect.insort() |