Tin mới
The built-in function dir() is used to find out which names a module defines. It returns a sorted list of strings:
To support this, Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module; definitions from a module can be imported into oth
To support this, Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module; definitions from a module can be imported into oth
A module can contain executable statements as well as function definitions. These statements are intended to initialize the module. They are executed only the first time the module name is encountered in an import statem
For efficiency reasons, each module is only imported once per interpreter session. Therefore, if you change your modules, you must restart the interpreter – or, if it’s just one module you want to test interactively, use
When a module named spam is imported, the interpreter first searches for a built-in module with that name. These module names are listed in sys.builtin_module_names. If not found, it then searches for a file named spam.p
site: Module responsible for site-specific configuration.
The installation-dependent default (by convention including a site-packages directory, handled by the site module).
The initialization of the sys.path module search path
When a module named spam is imported, the interpreter first searches for a built-in module with that name. These module names are listed in sys.builtin_module_names. If not found, it then searches for a file named spam.p
compileall: Tools for byte-compiling all Python source files in a directory tree.
The module compileall can create .pyc files for all modules in a directory.
winreg: Routines and objects for manipulating the Windows registry.
These two variables are only defined if the interpreter is in interactive mode.
These two variables are only defined if the interpreter is in interactive mode.
builtins: The module that provides the built-in namespace.
The built-in function dir() is used to find out which names a module defines. It returns a sorted list of strings: