How do I determine if my python shell is executing in 32bit or 64bit?

前端 未结 18 1139
北恋
北恋 2020-11-22 04:25

I need a way to tell what mode the shell is in from within the shell.

While I\'m primarily an OS X user, I\'d be interested in knowing about other platforms as well.<

18条回答
  •  花落未央
    2020-11-22 04:49

    Platform Architecture is not the reliable way. Instead us:

    $ arch -i386 /usr/local/bin/python2.7
    Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import platform, sys
    >>> platform.architecture(), sys.maxsize
    (('64bit', ''), 2147483647)
    >>> ^D
    $ arch -x86_64 /usr/local/bin/python2.7
    Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import platform, sys
    >>> platform.architecture(), sys.maxsize
    (('64bit', ''), 9223372036854775807)
    

提交回复
热议问题