class dheepak():
age = 23
name = "dheepak sasi"
ankit = getattr(dheepak, "hostname", ' ')
if ankit == None:
print "Shanaya"
else:
print "byee"
mani = dheepak.age
print ankit
如果主機名不存在,它應該打印Shanaya如果主機名存在比打印byee。和主機名值從另外一個程序來有時說到有時不如何檢查變量是否爲空?
或者http://stackoverflow.com/questions/9926446/how-to-check-whether-a-strvariable-is-empty-or-not –