'2014/05'에 해당되는 글 1건

  1. 2014.05.08 Python 버전 알아내기

Pytghon 스크립트로 버전을 알아내는 방법 중에 하나는

import sys

sys.version_info

를 이용하는 것이다.

 

* Pyhoin 3.3 의 경우

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=3, micro=3, releaselevel='final', serial=0)
>>> sys.version_info > (2, 4)
True
>>> sys.version_info >= (2, 4)
True
>>> sys.version_info >= (3, 0)
True

>>> type(sys.version_info)
<class 'sys.version_info'>

 

 

* Python 2.7 의 경우

Python 2.7.5 (default, Oct  2 2013, 22:34:09)
[GCC 4.8.1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)
>>> sys.version_info > (2, 4)
True
>>> sys.version_info > (2, 7)
True
>>> sys.version_info >= (2, 7)
True
>>> sys.version_info >= (2, 8)
False

>>> sys.version_info >= (3, 0)
False

>>> type(sys.version_info)
<type 'sys.version_info'>

 

 

 

Posted by Scripter

댓글을 달아 주세요