• 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
    '''
    
  • 相关阅读:
    获取网页页面高度
    统计建模与R软件习题二答案
    R for installing package 'omg'
    R: for installing package 'RODBC'
    svm
    map(int, ..) 与 int() 的区别
    python: list[-1] 与 list[-1:] 的区别
    logisticregression
    bayes
    机器学习之python: kNN
  • 原文地址:https://www.cnblogs.com/yaos/p/14014370.html
Copyright © 2020-2023  润新知