python源代码中的sys模块在哪里? [英] where is the sys module in python source code?

查看:661
本文介绍了python源代码中的sys模块在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python源目录中的Python/Lib或Python/Modules下找到了大多数python模块,但是sys(导入sys)模块在哪里?我没找到.

I have found most python modules in python source directory, under Python/Lib or Python/Modules ,but where is the sys (import sys) module ? I didn't find it .

推荐答案

答案

我在这里找到它:./Python/sysmodule.c

如果您使用的是Linux或Mac OS X,并且有疑问,只需在Python目录中尝试find . -name 'sysmodule.c'.

If you're on Linux or Mac OS X, and in doubt, just try find . -name 'sysmodule.c' in the Python directory.

我发现它的方法是通过在整个Python目录中搜索字符串"platform"(使用TextMate),就像我以前使用的那样. sys.platform之前的sys.platform模块...可以使用grepxargs完成类似的操作.

The way I found it was by searching for the string "platform" throughout the Python directory (using TextMate), as I've used e.g. sys.platform before from the sys module... something similar can be done with grep and xargs.

另一个建议可能是:for i in ./**/*.c ; do grep -H platform $i ; done

这将循环浏览当前位于文件树上方任何位置的所有*.c文件,并在文件中搜索"platform". -H标志将确保我们获得文件名路径,以便我们可以将匹配项追溯到找到它们的文件.

This will loop through all *.c files present in anywhere up the file tree you're currently located at, and search the file for "platform". The -H flag will ensure we get a filename path so we can trace the matches back to the files they are found in.

这篇关于python源代码中的sys模块在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆