Python - 我可以知道是否发生打印 [英] Python - can i know if a printing occurred or not
本文介绍了Python - 我可以知道是否发生打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个简单的python脚本。
在脚本中我使用
I wrote a simple python script. During the script i'm using
os.system ("diff file1 file2")
来检查两个文本文件是否相似。
我知道文件是类似的,如果没有打印出来。
如果没有打印,我想打印出一些
到命令行,像>文件是类似的。
to check if two text files are similar or not. I know the files are similar if nothing is being printed out. In case nothing is being printed, i'd like to print out something to the command line like "> the file are similar".
任何想法?
推荐答案
>>> import filecmp
>>> filecmp.cmp('file1.txt', 'file1.txt')
True
如果 True
,那么只是打印消息,两者都是类似的
filecmp - 逐个字节有效的比较是
if True
then just print message like both are similar
filecmp- A byte by byte efficient comparison it is
这篇关于Python - 我可以知道是否发生打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文