python中的dir(sys)没有给出预期的输出

2024-04-25 03:31:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的python程序(测试.py)我把它当作

Python3测试.py在安装了python3的ubuntu12.04机器上

import sys

dir(sys)


for i in sys.argv:
        print(i)


dir()

程序的输出是

test.py

这是for循环的输出。我指的是这本在线书籍 Python Online Tutorial 我希望dir(sys)的输出是

['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__s
tderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_compact_freelists',
'_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_names', '
byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle'
, 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable',
'exit', 'flags', 'float_info', 'getcheckinterval', 'getdefaultencoding', 'getfil
esystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof',
'gettrace', 'getwindowsversion', 'hexversion', 'intern', 'maxsize', 'maxunicode
', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platfor
m', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'setrecursionlimit
', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_in
fo', 'warnoptions', 'winver']

为什么我不能得到那个输出?你知道吗


Tags: pathinpy程序infocacheforversion