2014-01-23 3 views
1

확인을 위해 무엇을 찾는 방법, 나는 DIR() 함수를 알고 있지만, 나는이 모든이 모듈은 파이썬

>>> dir(sys) 
['__displayhook__', '__doc__', '__excepthook__', '__loader__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_debugmallocstats', '_getframe', '_home', '_mercurial', '_xoptions', 'api_version', 'argv', 'base_exec_prefix', 'base_prefix', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval', 'gettrace', 'getwindowsversion', 'hash_info', 'hexversion', 'implementation', 'int_info', 'intern', 'last_traceback', 'last_type', 'last_value', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'thread_info', 'version', 'version_info', 'warnoptions', 'winver'] 

나는이 중 무엇을 모르는 얻을. 나는 도움() 함수를 들어,하지만 나를 위해 작동하지 않거나 내가 추가 할 때 '그것은 나에게 당신은 dir 전화 정확히 같은 방식으로 help 전화 어떤 정보

>>> help(path) 
Traceback (most recent call last): 
    File "<pyshell#22>", line 1, in <module> 
    help(path) 
NameError: name 'path' is not defined 

>>> help('path') 
no Python documentation found for 'path' 

답변

3

를 제공하지 않습니다'. 따라서 :

>>> import sys 
>>> help(sys) 

Help on built-in module sys: 

NAME 
    sys 

FILE 
    (built-in) 

MODULE DOCS 
    http://docs.python.org/library/sys 

DESCRIPTION 
    This module provides access to some objects used or maintained by the 
    interpreter and to functions that interact strongly with the interpreter. 
... (lot of text follows) 

아무것도 찾을 수있는 모듈이나 기호 경로 help(path)이 없기 때문에. 따옴표를 추가하면 아무 도움이되지 않습니다. 그러나 : 그것은 변수에 전달 된 객체, list의 클래스에 대한 도움말을 인쇄하는 것이

>>> help(sys.path) 

Help on list object: 

class list(object) 
| list() -> new empty list 
... (lot of text follows) 

그러나 참고. 변수는 파이썬에서 first-class 객체가 아니기 때문에 인수가 sys.path에서 비롯된 것이고 모듈의 도움말 만 찾을 수 있습니다. 함수에는 함수 객체에 연결된 도움말이 있으므로 help은 전달한 특정 함수에 대한 도움말을 인쇄합니다.

+0

아 완벽한, 두 번째 코드는 내가 필요한 것입니다. 고맙습니다 – Atlas

1

help()을 통해 제공되는 기본 제공 설명서 이외에도 excellent online documentation을 잊지 마세요. module index (Python 2 링크)을 보거나 python sys.path과 같은 코드를 검색 할 수 있으며 일반적으로 첫 번째 링크를 클릭하면 바로 연결됩니다. 여기에 있으면 왼쪽 상단에있는 드롭 다운 메뉴를 통해 사용중인 정확한 버전을 선택할 수 있습니다.

관련 문제