Python「內建函數」(built-in functions)就是不用 import,隨時可以直接呼叫的函數,像 print()、len()、range() 這些,都算。
一、常見的 Python 內建函式列表
下面這些是不需要 import 就能直接用的函式/型別建構子(以 Python 3.10+ 為主):
1. 數學與數值計算相關
abs(x)round(number[, ndigits])pow(x, y[, mod])divmod(a, b)sum(iterable[, start])min(iterable, *[, key])/min(arg1, arg2, *args[, key])max(iterable, *[, key])/max(arg1, arg2, *args[, key])
2. 型別轉換 / 建構子
bool(x)int(x[, base])float(x)complex([real[, imag]])str(object='')bytes([source[, encoding[, errors]]])bytearray([source[, encoding[, errors]]])memoryview(obj)object()(最基礎的物件)
3. 容器與序列操作
list([iterable])tuple([iterable])dict([mapping-or-iterable])set([iterable])frozenset([iterable])range(stop)/range(start, stop[, step])len(s)sorted(iterable, *, key=None, reverse=False)reversed(seq)enumerate(iterable, start=0)zip(*iterables)filter(function, iterable)map(function, iterable, ...)any(iterable)all(iterable)
4. 字串與編碼 / 表示
chr(i)(整數 → 字元)ord(c)(字元 → 整數)ascii(object)(只用 ASCII 顯示)format(value[, format_spec])bin(x)(轉二進位字串)oct(x)(轉八進位字串)hex(x)(轉十六進位字串)repr(object)(官方表示形式)
5. 物件與反射(反射 = 在執行時檢查/操作物件)
type(obj)/type(name, bases, dict)isinstance(obj, classinfo)issubclass(class, classinfo)id(obj)getattr(obj, name[, default])setattr(obj, name, value)hasattr(obj, name)delattr(obj, name)vars([object])dir([object])
6. 類別相關
classmethod(function)staticmethod(function)property(fget=None, fset=None, fdel=None, doc=None)super([type[, object-or-type]])
7. I/O 相關
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)input([prompt])open(file, mode='r', ...)
8. 執行 / 編譯、命名空間
eval(expression[, globals[, locals]])exec(object[, globals[, locals]])compile(source, filename, mode, ...)__import__(name, globals=None, locals=None, fromlist=(), level=0)globals()locals()
9. 非同步迭代(Python 3.10+)
aiter(async_iterable)anext(async_iterator[, default])
10. 除錯與輔助
breakpoint(*args, **kws)help([object])
補充:dir(__builtins__)裡面還會看到一堆 例外類別(例如ValueError、TypeError…)和一些互動環境用的物件(quit、exit等),這些通常不會被歸類在「內建函式」列表裡,但也同樣是內建名稱。
二、自己在 REPL 裡看所有內建名稱
你可以在 Python 裡這樣看所有內建(包含函式、型別、例外等):
import builtins
print(dir(builtins))
如果只想看「常用的函式 + 型別建構子」,平常記住上面那幾群就很夠用了,其餘真的忘了:help() 一叫、文件一查就好。

