Python3 calls cmd to copy the file, and passes the test in win7. For more information, see.
The code is as follows:
Import OS
Def load ():
Filename = OS. getcwd () + r' \ fromto.txt'
If OS. path. isfile (filename ):
F = open (filename)
Try:
Lines = f. readlines ()
Finally:
F. close ()
Return lines
Else:
Print('create fromto.txt .')
Input ()
Exit ()
Def display (_ lines ):
Linenum = 1
S = 'Destination file \ n' of the serial number source file'
For line in _ lines:
S + = str (linenum) + ''+ line
Linenum + = 1
Return s + '\ n' + R' enter the serial number :'
Def work (s, _ lines ):
Cmd = r 'copy/y' + _ lines [int (s)-1]
Print (cmd)
OS. system (cmd)
If _ name _ = "_ main __":
Lines = load ()
While True:
Try:
S = input (display (lines). strip ()
If s. lower () = 'eg ':
Break
If int (s) = 0:
Lines = load ()
Print ('reloaded ')
Continue
Work (s, lines)
Except t:
Input ('-- Error --')
The fromto.txt format is the source file on the left of each line, and the target file (or target directory) on the right ).
In fact, it is packaged with copy.
Fromto.txt content
The code is as follows:
D: \ txt \ 1.txt d: \ txt \ 2.txt
D: \ txt \ *. txt d: \ txt2 \