Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法让 PyYaml 的默认加载器成为 CLoader。所以不必做
yaml.load(f, Loader=yaml.CLoader)
它只是默认为 CLoader,所以我可以这样做:
yaml.load(f)
我认为您正在寻找的是functools.partial:
import functools myload=functools.partial(yaml.load,Loader=yaml.CLoader) myload(f)