代码示例(Python):
import filecmp
def check_files_match(filepath1, filepath2):
if filecmp.cmp(filepath1, filepath2):
print("The files match")
else:
print("The files do not match")
说明:
我们使用Python的filecmp模块来进行文件比较,并且编写了一个名为check_files_match的函数来执行此操作。该函数接受两个文件路径作为参数,并根据文件是否匹配打印相应的消息。
使用方法:
您可以按照以下方式使用此函数:
check_files_match('path/to/file1', 'path/to/file2')
这行代码将比较具有给定路径的两个文件,如果它们匹配,则打印消息"The files match",否则打印消息"The files do not match"。请确保替换实际的文件路径。
希望这可以帮助您来解决问题!