我的子文件夹中有多个文件需要复制到另一个具有指定子文件夹名称和日期时间的主文件夹,意味着A1/B/C/D/D.txt复制到A2/B/C/D/datetime_username/D.txt,目录 B、C、D 中有多个文件夹,也许是 B1、B2...用户决定要传输哪个子文件夹
现在我正在尝试打印 D 文件夹的路径。我尝试的文件夹位于我的桌面上。
import os, shutil
os.chdir('C:\\path')
def main():
lvl1 = ['Typ','GFP2']
lvl2 = ['A0','A1']
lvl3 = ['SCAN','MBIST']
project = input("Enter project: ")
#Validation
for s in lvl1:
if s == project:
src1 = 'IDC\\{}'.format(s)
stepping = input("Enter Stepping: ")
for l2 in lvl2:
if l2 == stepping:
#shutil.copytree()
src2 = src1+'\\{}'.format(l2)
thirdlvl = input("Enter SCAN/MBIST: ")
for l3 in lvl3:
if l3 == thirdlvl:
src3 = src2+'\\{}'.format(l3)
print(src3)
else:
print("Stepping not found")
break
else:
print("Project name not found")
main()
我会得到'''
Enter project: Typ
Enter Stepping: A0
Enter SCAN/MBIST: SCAN
IDC\Typ\A0\SCAN
Stepping not found
'''
如果我想仅在未找到步进时打印“未找到步进”,现在即使存在此文件夹也会打印它。
谢谢
慕虎7371278
相关分类