xxxxxxxxxx
import subprocess
def get_latest_ubuntu_version():
try:
output = subprocess.check_output(['lsb_release', '-rs'], universal_newlines=True)
ubuntu_version = float(output.strip())
return ubuntu_version
except Exception as e:
print(f"Error: {e}")
return None
latest_version = get_latest_ubuntu_version()
if latest_version is not None:
print(f"The latest version of Ubuntu is {latest_version}")
xxxxxxxxxx
import requests
from bs4 import BeautifulSoup
# Retrieve the Ubuntu release page
url = "https://wiki.ubuntu.com/Releases"
response = requests.get(url)
soup = BeautifulSoup(response.content, "html.parser")
# Find the latest version
latest_version = soup.find("table").find("tr").find("td").text.strip()
print("The latest Ubuntu version is:", latest_version)
xxxxxxxxxx
import subprocess
# Run terminal command to get Ubuntu version
version = subprocess.check_output(['lsb_release', '-d']).decode('utf-8').strip().split('\t')[1]
print(f"The latest version of Ubuntu is: {version}")