if事件中的Python文件cmp.cmp(';old#u index.html';,';new#index.html';)

if事件中的Python文件cmp.cmp(';old#u index.html';,';new#index.html';),python,file,if-statement,Python,File,If Statement,如何在if问题中使用此python命令: import filecmp filecmp.cmp('old_index.html', 'new_index.html') 这些命令的答案是对的还是错的。 这样我就可以在文件相同或不相同时执行某些操作 感谢您的帮助您只需在if语句中使用它,如下所示 if filecmp.cmp('old_index.html', 'new_index.html'): # Do whatever you want if the files are the sa

如何在if问题中使用此python命令:

import filecmp
filecmp.cmp('old_index.html', 'new_index.html')
这些命令的答案是对的还是错的。 这样我就可以在文件相同或不相同时执行某些操作


感谢您的帮助

您只需在
if
语句中使用它,如下所示

if filecmp.cmp('old_index.html', 'new_index.html'):
    # Do whatever you want if the files are the same
    print("Both the files are same")
else:
    # Do whatever you want if the files are NOT the same
    print("No, the files are NOT the same")

我想你可以用
bool
  if filecmp.cmp('old.html','new.html')==False:
  #do something like-
    print 'files are not equal'
  #same code for True value