#!/usr/local/python
import os,sys
def delrpmpackage(rpmname):
rpmlist=os.system('rpm -qa|grep -i rpmname')
print rpmlist
lens=len(rpmlist)
for i in range(0,lens):
os.system('rpm -e rpmlist
')
print("[info]ok,delete rpmpackage %s succeed" %(rpmname))
delrpmpackage('ftp')
為什麼的輸出的是:
[root@localhost python]# python rpmdel.py
256
Traceback (most recent call last):
File "rpmdel.py", line 10, in ?
delrpmpackage('ftp')
File "rpmdel.py", line 6, in delrpmpackage
lens=len(rpmlist)
TypeError: len() of unsized object
我的目的是刪除rpm包,有誰可以指點下!