gpt4 book ai didi

python - 在安装的pygame目录中哪里可以找到pygame.init()方法?

转载 作者:太空宇宙 更新时间:2023-11-04 02:01:26 26 4
gpt4 key购买 nike

我找不到 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 pygame模块的init方法的来源。

我不知道在 Linux 中编译的文件是什么样的,因为我目前没有准备好 pygame 的 Linux 机器。但是在 Windows 上,你会发现例如base.cp37-win32.pyd,它基本上是一个包含已编译 C 代码的 DLL。

关于python - 在安装的pygame目录中哪里可以找到pygame.init()方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55611686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com