前言

在Linux 系统获取当前python版本,方便进行下一步操作

代码

#!/bin/bash
set -eoxu pipefail

python_version=$(python3 --version 2>&1 |awk '{print $2}'|awk -F '.' '{printf "%d.%d", $1,$2}')

if [ $python_version == 3.7 ]; then
    echo "python3 version is 3.7"
elif [ $python_version == 3.10 ]; then
    echo "python3 version is 3.10"
else
    echo "python3 version is none"
fi

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注