Permanently add a directory to PYTHONPATH?

前端 未结 19 1637
别那么骄傲
别那么骄傲 2020-11-22 01:12

Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I

19条回答
  •  孤城傲影
    2020-11-22 01:39

    Shortest path between A <-> B is a straight line;

    import sys
    if not 'NEW_PATH' in sys.path:
      sys.path += ['NEW_PATH']
    

提交回复
热议问题