How to determine the USB stick insert or not?
Incoming group: 548377875 to get dozens of sets of PDFs Oh!
As the headline shows, we really only used 10 lines (actually 11 lines, rounding up a whole:) to complete the "virus". We can find the contents of the USB and lie in the home directory after half a minute of insertion.
How do I select a copy of a file?
Let me give you an example.
I created the Testwalk folder in a directory, there are file123.txt three files, folder123 three folders, where Folder1 file File4.txt and Folder4
Now let's test it.
Root is the current location, and it will take all the folders under the./testwalk/as the root directory and search down
OK, we now need to recursive USB folder, find all the file, look at the size, if less than, such as 3M, copy into the home, greater than to go.
Shutil Module
Os.path.getsize () Judging size
Os.path.getsize (file name) returns a number in bytes, and if used to view the file size, we need to manually write a function to convert it into an easy-to-read form.
In summary, the modification time of each file can be filtered to copy only those files that have been modified or added during a specific period, which is useful in certain situations.
Almost beaten by a counselor! Just because I wrote him a USB virus! Python thief