打开Python看到如下信息:
Python 2.7(r27:82525,Jul 42010, 07:43:08)[MSC v.150064 bit (AMD64)] on win32Type"help","copyright","credits" or"license" for more information.
>>> import sys, platform
>>> platform.architecture()
('64bit','WindowsPE')
>>> sys.maxint2147483647
总是有些疑惑:我的python到底是32位还是64位呢?解释各不相同,
<code><span class="pun">第一种解释:<span class="pun"><span style="font-family:Arial;">I've installed Python 2.7 from the python-2.7.amd64.msi package from python.org. It installs and runs correctly, but seems to be in 32-bit mode, despite the fact that the installer was a 64 bit installer.参见:<a target=_blank target="_blank" href="http://stackoverflow.com/questions/3411079/why-does-the-python-2-7-amd-64-installer-seem-to-run-python-in-32-bit-mode%E3%80%82">http://stackoverflow.com/questions/3411079/why-does-the-python-2-7-amd-64-installer-seem-to-run-python-in-32-bit-mode。</a></span></span></span></code>
<code><span class="pun"><span class="pun"><span style="font-family:Arial;"><span style="font-family:Courier New;">系统仍然维持了一个sys<span class="pun">.</span><span class="pln">maxint的变量,值为 </span><span class="lit">2147483647。但是并不一定说这个python就是32位的。</span></span></span></span></span></code>
<code><span class="pun"><span class="pun"><span style="font-family:Arial;">第二种解释:</span></span></span></code>
<code><span class="pun">Python 2.7: Python的版本是2.7的</span></code>
<code><span class="pun">Win32 -> 指的就是Windows系统;</span></code>
<code><span class="pun">64 bit- > 指的是Windows是64位的;</span></code>
<code><span class="pun">AMD64 -> 指的就是 CPU是x64的</span><span class="pln"> </span></code>
第三种解释:
如何查看python是32位还是64位:参见 :http://blog.csdn.net/waleking/article/details/7566842
import struct
struct.calcsize("P")
如果是4,说明是32位的;如果是其他的是,64位的。struct.calcsize用于计算格式字符串所对应的结果长度。