elif user == str(3):
src = input("Enter the location of the file you wish to copy: ")
print('\n')
dstLocation = input("Next, enter the location where you wish to copy the file to (DO NOT ENTER FILE): ") #asks user to input destination location
dstFile = input("Enter the file name and extension: (e.g. abc.txt) ") #ask user to input destination filename
dst = os.path.join(dstLocation, dstFile) #Appends the dstLocation and dstFile
if os.path.isfile(src) and os.path.isdir(dstLocation):
while count < 1:
shutil.copyfile(src, dst)
print('Copy successful')
count = count + 1
else:
print('Copy unsuccessful')
我仍在学习 Python,但除了 try-except 方法之外,这是附加文件以进行复制的适当方法吗?
还有一种方法可以使用 switch 语句,或者在 Python 中可以接受多个 if 语句