Python文档(我检查了2.7和3.4)说明:
在OS X上,find_library()尝试几个预定义的命名方案和路径来定位库,如果成功则返回完整路径名:
然后给出来自两个文件夹的示例:/usr/lib
和/System/Library
.我想这不是完整列表,因为我有从python查找库的经验/usr/local/lib
.在Mac OS X上搜索python ctypes find_library的完整路径列表是什么?
我需要将从 Python 调用的 PowerShell stdout 解码为 Python 字符串。
\n\n我的最终目标是以字符串列表的形式获取 Windows 上网络适配器的名称。我当前的函数如下所示,并且在使用英语的 Windows 10 上运行良好:
\n\ndef get_interfaces():\n ps = subprocess.Popen(['powershell', 'Get-NetAdapter', '|', 'select Name', '|', 'fl'], stdout = subprocess.PIPE)\n stdout, stdin = ps.communicate(timeout = 10)\n interfaces = []\n for i in stdout.split(b'\\r\\n'):\n if not i.strip():\n continue\n if i.find(b':')<0:\n continue\n name, value = [ j.strip() for j in i.split(b':') ]\n if name == b'Name':\n interfaces.append(value.decode('ascii')) # This fails for other users\n return interfaces\n
Run Code Online (Sandbox Code Playgroud)\n\n其他用户使用不同的语言,因此value.decode('ascii')
其中一些用户会失败。例如,一位用户报告说更改为decode('ISO 8859-2')
对他来说效果很好(因此它不是 …