I am trying to assign the return value of python --version to a variable using the code below.:
#! /usr/bin/env python import os import sys import subprocess os.system('pwd') print ("check the version of python") output = subprocess.Popen(["python --version"], stdout=subprocess.PIPE, shell=True) (ver, error)= output.communicate() print "python is:",ver The output I'm getting is :
/home/mobaxterm/Desktop/mypy check the version of python Python 2.7.10 python is: Please let me know what I am missing.
Thanks in advance.
sys.version_info, right?