zoukankan      html  css  js  c++  java
  • 各种搜索路径问题

    python中import一个模块时python解释器的搜索目录顺序:

    参考python帮助文档

    The Module Search Path

    When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variablesys.pathsys.path is initialized from these locations:

    • the directory containing the input script (or the current directory).
    • PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
    • the installation-dependent default.

    After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.

    这里也有一篇: Understanding imports and PYTHONPATH

    环境变量

    PATH是告诉操作系统到哪些目录里找可执行文件

    PYTHONPATH是告诉python解释器到哪些目录去找要加载的模块

    Windows找DLL的顺序

    With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:

    The directory where the executable module for the current process is located.

    • The current directory.
    • The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
    • The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
    • The directories listed in the PATH environment variable.

    参考:msdn

  • 相关阅读:
    判断UpLoader是否安装了Flash
    事务
    AMQP
    分布式领域CAP理论
    查看数据库所有表的所有字段
    拼分页方法
    Website English Comments
    SQL语句执行时间测试
    一般处理程序返回json
    MVC Action返回Json
  • 原文地址:https://www.cnblogs.com/xianzhon/p/3767370.html
Copyright © 2011-2022 走看看