How to suppress the return of shutil.copy2() in Python?

587 views Asked by At

It returns the target file path to the console after executing shutil.copy2(), which is annoying. enter image description here

I would like to silent the output.

1

There are 1 answers

0
CcMango On

add _ = before shutil.copy2 will assign the message to _ to avoid it to be print to console. _ can be changed to any other names you like. enter image description here