'itertools'文件在哪里

zjm*_*126 9 python python-itertools

import itertools
print itertools#ok
Run Code Online (Sandbox Code Playgroud)

代码还可以

但我找不到itertools文件.

谁能告诉我'itertools文件'在哪里


我的代码运行python2.5

import itertools
print itertools.__file__


Traceback (most recent call last):
  File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in <module>
    print itertools.__file__
AttributeError: 'module' object has no attribute '__file__'
Run Code Online (Sandbox Code Playgroud)

Ant*_* P. 18

>>> import itertools
>>> itertools.__file__
'/usr/lib64/python2.6/lib-dynload/itertools.so'
Run Code Online (Sandbox Code Playgroud)

文件名结尾的事实.so意味着它是用C编写的扩展模块(而不是普通的Python模块).如果您想查看源代码,请下载Python源代码并查看Modules/itertoolsmodule.c(您也可以在浏览器中查看它http://svn.python.org/view/python/trunk/Modules/itertoolsmodule.c ?view = log).

编辑(作为下面评论的答案):它也适用于Python 2.5:

Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import itertools
>>> itertools.__file__
'/usr/lib/python2.5/lib-dynload/itertools.so'
Run Code Online (Sandbox Code Playgroud)