• Python模块和模块引用(一)


    """
    import my_module as mm
    
    courses = ['History','Math','Physics','CompSci']
    
    index = mm.find_index(courses, 'Math')
    print (index)
    """
    
    """
    from my_module import find_index
    
    courses = ['History','Math','Physics','CompSci']
    
    index = find_index(courses, 'Math')
    print (index)
    """
    
    """
    from my_module import find_index as fi, test
    
    courses = ['History','Math','Physics','CompSci']
    
    index = fi(courses, 'Math')
    print (index)
    print(test)
    """
    
    """
    from my_module import *
    
    courses = ['History','Math','Physics','CompSci']
    
    index = find_index(courses, 'Math')
    print (index)
    print(test)
    """
    
    '''
    from my_module import find_index, test
    import sys
    
    courses = ['History','Math','Physics','CompSci']
    
    index = find_index(courses, 'Math')
    
    print(sys.path) # print out list of directories imported
    '''
    
    '''
    Imported my_module...
    ['/Users/Yao/python_learn', #this directory was added automatically
    '/Users/Yao/Documents',
    '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
    '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
    '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
    '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
    '''
    
    '''
    import sys
    sys.path.append('Users/...') # add director for importing modules
    '''
    
  • 相关阅读:
    JDBC 详解
    Class.forName() 详解
    23种设计模式
    MVC 模式
    Ant 打包 问题
    Jedis操作Redis--SortedSet类型 (会自然排序)
    在JSP中常见问题,防止SpringMVC拦截器拦截js等静态资源文件的解决方案
    在idea中使用@Test注解报错的解决方案
    判断返回的对象是否为空
    使用标准的日期格式化过程
  • 原文地址:https://www.cnblogs.com/yaos/p/14014370.html
Copyright © 2020-2023  润新知