显示当前目录所有py文件的类名和函数名,当前目录py函数名,import osimp


import osimport sysdef Show_file():    print "lines    filename"    for i in os.listdir(os.getcwd()):        if os.path.isfile(i) and not i.startswith("__init__"):            print os.popen('wc -l %s' % i).read().split('\n')[0]    print ''def Query_file():    filename = raw_input('Input the one filename show above[q to quit]:')    if filename == 'q':        sys.exit()    file = open(filename,'r').readlines()    print '\n\n'    for i in file:        if i.startswith('class') or i.startswith('def') or i.startswith('    def'):            print i,if __name__ == '__main__':    Show_file()    Query_file()

评论关闭