或在Windows下: python -vv -c" import spam" 2out.txt findstr spam out out .txt ) 为什么以及规则是什么? 如果您希望Python能够导入二进制扩展名,请确保 使用它所查找的名称。 < / F> On windows everything is ''.pyd'' but there seems to be two ways to getthis on unix?Why and what is the rule? 解决方案 llothar wrote:On windows everything is ''.pyd'' but there seems to be two ways to getthis on unix?If you attempt to import the module "spam" on Windows, Python looks for"spam.dll" and "spam.pyd" (in addition to "spam.py/spam.pyw/spam.pyc" etc)On most Unix platforms, Python looks for "spam.so" and "spammodule.so".You can check what suffixes a given Python version uses via the "imp"module:>>import impimp.get_suffixes()To see *where* Python is looking as well, use the "-vv" flag: python -vv -c "import spam"...# trying spam.so# trying spammodule.so# trying spam.py# trying spam.pyc... etc(-vv prints loads of stuff, so you may want to use "grep" to filter outthe stuff you''re interested in: python -vv -c "import spam" 2>&1 | grep spamor, under Windows:python -vv -c "import spam" 2out.txtfindstr spam out.txt)Why and what is the rule?If you want Python to be able to import your binary extension, make sureto use a name it looks for.</F> 这篇关于二进制扩展何时获取文件扩展名'.pyd',何时获取'.so'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 23:49