Этот пример показывает, как обновить список Python® имен папок с помощью метода append.
Создайте список папок P с помощью переменной sys.path Python.
P = py.sys.path;
Отобразите функции Python для типа list.
methods(P)
Methods for class py.list: append clear eq gt le mtimes pop sort cell copy extend index list ne remove char count ge insert lt plus reverse Call "methods 'handle' " for methods of py.list inherited from handle.
Считайте документацию для append.
py.help('list.append')
Help on method_descriptor in list:
list.append = append ...
L.append object -> None -- append object to end
Добавьте текущую папку в конец пути.
append(P,pwd)
Отобразите количество папок на пути. Список имеет элементы py.len. Ваше значение может отличаться. Типом этого номера является py.int.
py.len(P)
ans =
Python int with properties:
denominator: [1×1 py.int]
imag: [1×1 py.int]
numerator: [1×1 py.int]
real: [1×1 py.int]
8