Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of filecmp module in Python

Shulou Source: shulou.com Published: 2022-06-03 17:37:11 09月17日 Update

Editor to share with you what is the use of the filecmp module in Python, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Description

1. Filecmp is a built-in module in python that compares the contents of files and folders.

2. There are two ways: filecmp.cmp compares the contents of two files to see if they match, and filecmp.cmpfile compares whether the specified files within the two files are equal.

Example

Import filecmp "" description: text.txt and text1.txt content are different, text.txt and text2.txt content are the same. "" Res1 = filecmp.cmp ("text.txt", "text1.txt", shallow=True) print ("comparison between text.txt and text1.txt: {}" .format (res1)) res2 = filecmp.cmp ("text.txt", "text2.txt", shallow=True) print ("comparison between text.txt and text2.txt: {}" .format (res2)) above are all the contents of this article entitled "what is the use of filecmp modules in Python?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content documents modules two articles same results not much most examples folders methods more knowledge industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Shulou Tech Info Docker MariaDB