前言
在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