- # 显示已经安装的python
- def GetPythonV(self, get):
- versions = []
- # sysv = public.ExecShell("/usr/bin/python --version")[1].split()[1]
- # 报错提示列表超出索引值
- # 改成下面的代码
- sysv = public.ExecShell("/usr/bin/python --version")[0].split()[1]
- data = public.ExecShell("/root/.pyenv/bin/pyenv versions")[0].split("\n")
- n = 0
- for v in data:
- if n == 0:
- n+=1
- continue
- if v == '':
- continue
- versions.append(v.strip())
- versions.append(sysv)
- versions.sort()
- versions.reverse()
- return versions
复制代码 |