例如:如果某值不存,但是必须需要此变量拥有一个值,在出现此类的异常,我们要主动赋值
try:
pwentry = pwd.Passwd(self.cfg).getpwnam(self.username)
self.uid = pwentry["pw_uid"]
self.gid = pwentry["pw_gid"]
self.home = pwentry["pw_dir"]
except:
self.uid = 1001
self.gid = 1001
self.home = '/home'