zoukankan      html  css  js  c++  java
  • 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
    '''
    
  • 相关阅读:
    会计期间勿关闭后台打开
    动态创建VIEW
    约束变量
    JS 图片懒加载
    如何在Javascript中对数组的遍历使用异步函数
    JavaScript之闭包
    面试:数组去重你会几种呀?
    JavaScript重构技巧-降低函数复杂度
    JavaScript的内置对象
    js/jQuery获取data-*属性值
  • 原文地址:https://www.cnblogs.com/yaos/p/7008552.html
Copyright © 2011-2022 走看看