我找不到 pygame.init() 函数。请看看我做了什么。
ckim@chan-ubuntu:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> print (pygame.__file__)
/usr/local/lib/python2.7/dist-packages/pygame/__init__.pyc
>>> pygame.init()
(6, 0)
所以我在 /usr/local/lib/python2.7/dist-packages/pygame 下搜索,但找不到模块 pygame 的 init() 源代码。在那里我找到了包含 init 的 base.so 文件(用 nm base.so 检查)。那么pygame不是安装了所有的源代码,一些用C或C++实现并由.so文件提供的函数和类型吗?
是的,pygame 的很大一部分是用 C 编写的。
Here's的来源init
pygame 模块的方法。
我不知道编译后的文件在 Linux 中是什么样子,因为我目前没有准备好 pygame 的 Linux 机器。但在 Windows 上,您会发现例如base.cp37-win32.pyd
,它基本上是一个包含已编译的 C 代码的 DLL。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)