The Python sys module contains functions related to the Python interpreter and its environment, which you can use DIR (SYS) to view the methods and member properties inside him
Copy Code code as follows:
Import Sys
Print dir (SYS)
Result
Copy Code code as follows:
[' __displayhook__ ', ' __doc__ ', ' __excepthook__ ', ' __name__ ', ' __package__ ', ' __stderr__ ', ' __stdin__ ', ' __stdout__ ', ' _clear_type_cache ', ' _current_frames ', ' _getframe ', ' _mercurial ', ' api_version ', ' argv ', ' builtin_module_names ', ' Byteorder ', ' call_tracing ', ' callstats ', ' copyright ', ' displayhook ', ' dllhandle ', ' dont_write_bytecode ', ' exc_clear ', ' Exc_info ', ' exc_type ', ' excepthook ', ' exec_prefix ', ' executable ', ' exit ', ' flags ', ' float_info ', ' float_repr_style ', ' Getcheckinterval ', ' getdefaultencoding ', ' getfilesystemencoding ', ' getprofile ', ' getrecursionlimit ', ' Getrefcount ', ' Getsizeof ', ' gettrace ', ' getwindowsversion ', ' hexversion ', ' long_info ', ' maxint ', ' maxsize ', ' maxunicode ', ' Meta_ Path ', ' modules ', ' path ', ' path_hooks ', ' path_importer_cache ', ' platform ', ' prefix ', ' py3kwarning ', ' setcheckinterval ' , ' Setprofile ', ' setrecursionlimit ', ' settrace ', ' stderr ', ' stdin ', ' stdout ', ' subversion ', ' Version ', ' Version_info ', ' Warnoptions ', ' winver ']
Copy Code code as follows:
Import Sys
Print Sys.path
Result
[' C:\\Documents and Settings\\username\\my documents\\aptana Studio 3 workspace\\python_test_project\\src ', ' C:\\ Documents and Settings\\username\\my Documents\\aptana Studio 3 workspace\\python_test_project\\src ', ' c:\\python27 ', ' C:\\python27\\dlls ', ' c:\\python27\\lib ', ' c:\\python27\\lib\\lib-tk ', ' C:\\python27\\lib\\plat-win ', ' C:\\ Python27\\lib\\site-packages ', ' c:\\python27\\lib\\site-packages\\wx-2.8-msw-unicode ', ' C:\\WINDOWS\\system32\\ Python27.zip ']
There's a Sys.path attribute inside. He is a list. In case Python imports a file or module in silence, he will first find the path to the module in the Sys.path. If not, the program will complain.
So we usually write our own programs. It is best to add your module path to the current module scan path, Eg:sys.path.append (' Your module name ') so that the program will not
Error due to no module found.