顺德公农庄 发表于 2015-12-15 09:53:19

Python学习:一个映射和过滤list的小练习


>>> import os
>>> import re
>>> for m in dir(os) if callable(getattr(os,m)) and re.search('^[^_]',m)]#列出os模块中的所有接口方法
['abort', 'access', 'chdir', 'chmod', 'close', 'dup', 'dup2', 'error', 'execl', 'execle', 'execlp','execlpe', 'execv', 'execve', 'execvp', 'execvpe', 'fdopen', 'fstat', 'fsync', 'getcwd', 'getcwdu','getenv', 'getpid', 'isatty', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir', 'open', 'pipe', 'popen', 'popen2', 'popen3', 'popen4', 'putenv', 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'spawnl', 'spawnle', 'spawnv', 'spawnve', 'startfile', 'stat', 'stat_float_times', 'stat_result', 'statvfs_result', 'strerror', 'system', 'tempnam', 'times', 'tmpfile', 'tmpnam', 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', 'waitpid', 'walk', 'write']
>>> for m in dir(os) if callable(getattr(os,m)) and re.search('^_',m)]#列出os模块中的所有私有方法
['_Environ', '_execvpe', '_exists', '_exit', '_get_exports_list', '_make_stat_result', '_make_statvfs_result', '_pickle_stat_result', '_pickle_statvfs_result']

页: [1]
查看完整版本: Python学习:一个映射和过滤list的小练习