Python的 - 检查,如果系统是32位还是64位,以确定是否运行功能或不? [英] Python - check if a system is 32 or 64 bit to determine whether to run the function or not?

查看:570
本文介绍了Python的 - 检查,如果系统是32位还是64位,以确定是否运行功能或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/1405913/how-do-i-determine-if-my-python-shell-is-executing-in-32bit-or-64bit-mode\">How我确定我的python外壳在32位或64位模式下执行?

我做了前面一个问题,从来没有得到答复,但我有更多的具体的事情,现在,所以希望能帮到你。

I made a question earlier that never got replied to, but I have something more specific now so hopefully you can help.

基本上送键库只出现安装我的Windows 32位系统上...

Basically the SendKeys library only appears to install on my 32 bit system of Windows...

所以我想知道是否有做的方式,所以这个功能,我会写会只在32位系统上执行?我知道有一个platform.architecture()方法来检查当前的系统,但它返回字符串('64','windowsPE的')。

So I was wondering if there is a way of making it so this function I am going to write will only execute on a 32 bit system? I realise there is a platform.architecture() method to check the current system, but it returns the string "('64bit', 'WindowsPE')".

我想知道是否有读这个字符串的64位部分正确地使该功能的工作方式。

I was wondering if there was a way to read the 64 bit part of this string to make this function work correctly.

例如,伪code:

checker = platform.architecture()
system = strip or read 64 bit from checker string somehow
if system == 64 bit
then warn system is 64 bit and won't run function
else run function

沿该线。除非有检查它的一个简单的方法 - 也许对使用的Python的版本(即32位或64位)

Along the line of that. Unless there is a simpler way of checking it - maybe against the version of Python used (ie 32 or 64 bit)

希望我已经正确地抓住了这个 - 我仍然相当新的节目。 :)

Hope I've grasped this correctly - I'm still rather new to programming. :)

推荐答案

这文档,试试这个code:

Following this documentation, try this code:

is_64bits = sys.maxsize > 2**32

请注意:如果这32位Python是一种64位操作系统上运行可以返回不正确的结果。

Note: this can return an incorrect result if 32bit Python is running on a 64bit operating system.

这篇关于Python的 - 检查,如果系统是32位还是64位,以确定是否运行功能或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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