我有以下代碼是從一個問題的工作分開。我試圖比較來自commands.getoutput(cmd)的兩個輸出,但即時獲取語法錯誤。據我所知,這可能是天生錯的,但也有人指出在做什麼我錯了比較輸出
def DiffGenerator():
try: sys.argv[1]
except: print "No Directory to scan defined\n"
try: sys.argv[2]
except: print "No delay time defined\n"
ScanDirectory = sys.argv[1]
if not os.path.exists(ScanDirectory):
print "Scan Directory does not exist :" + ScanDirectory
cmd = "ls -l " + ScanDirectory
try:
DiffFileA = commands.getoutput(cmd)
print "Printing DiffFileA" + DiffFileA
time.sleep(1)
DiffFileB = commands.getoutput(cmd)
if operator.ne(DiffFileA, DiffFileB)
print "New File placed within " + ScanDirectory
except:
print "BLAH"
我是新來編寫Python這樣的IM確保ü可以理解爲什麼我會遇到這樣的事情。什麼是更好的方式去A!= B – paultop6 2011-02-18 11:27:12