如何使用 python apt API 在 Ubuntu 上添加 PPA?

ans*_*ker 2 package-management python apt python-2.7 16.04

在 python 2.7 上使用 Python apt API?我一直无法找到如何做到这一点。

mur*_*uru 5

您将不得不使用 Python 3,这应该不是问题,因为当前的 Ubuntu 版本(除了即将成为 EOL 12.04 的版本)都默认安装了 Python 3,并且默认情况下仅使用 Python3。使用aptsources.sourceslist.SourcesList对象:

#! /usr/bin/python3

import aptsources.sourceslist as sl

sources = sl.SourcesList()
sources.add('deb', 'mirror://mirrors.ubuntu.com/mirrors.txt', 'xenial', ['main'])
sources.save()
Run Code Online (Sandbox Code Playgroud)