system.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:libdesktop 作者: bharadwaj-raju 项目源码 文件源码
def is_in_path(program):
    '''
    Check if a program is in the system ``PATH``.

    Checks if a given program is in the user's ``PATH`` or not.

    Args:
            program (str): The program to try to find in ``PATH``.

    Returns:
            bool: Is the program in ``PATH``?
    '''

    if sys.version_info.major == 2:
        path = os.getenv('PATH')
        if os.name == 'nt':
            path = path.split(';')
        else:
            path = path.split(':')
    else:
        path = os.get_exec_path()

    for i in path:
        if os.path.isdir(i):
            if program in os.listdir(i):
                return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号