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.
我想导入一个不在 Python 搜索路径中的模块。我能想到两种对我都没有吸引力的方法:
import sys; sys.path.append("/path/to/mymodule"); import mymodule
PYTHONPATH=$PYTHONPATH:/path/to/mymodule python myfile.py
有没有更好/更清洁的方法来做到这一点?如果不是,首选哪一个?