我怎么能从壳内告诉壳处于什么模式?

我已经试着查看了平台模块,但它似乎只告诉您“用于可执行文件的位架构和链接格式”。我的二进制文件被编译为64位(我在OS X 10.6上运行),所以它似乎总是报告64位,即使我使用这里描述的方法强制32位模式。


当前回答

试试这个:

import platform
platform.architecture()

其他回答

对于32位,它将返回32,对于64位,它将返回64

import struct
print(struct.calcsize("P") * 8)
import sys
print(sys.version)

3.5.1 (v3.5.1:37a07cee5969, 2015年12月6日01:54:25)[MSC .1900 64位(AMD64)]

对于非编程解决方案,请查看活动监视器。它将64位进程的体系结构列为“Intel(64位)”。

C:\Users\xyz>python

Python 2.7.6 (default, Nov XY ..., 19:24:24) **[MSC v.1500 64 bit (AMD64)] on win
32**
Type "help", "copyright", "credits" or "license" for more information.
>>>

在CMD中点击python后

基本上是Matthew Marshall答案的变体(使用来自std.library的struct):

import struct
print struct.calcsize("P") * 8