擅长:python、mysql、java
<p>好吧,最后我还是自己完成了。如果有人感兴趣,您可以找到下面的代码示例。它非常简单,当然可以优化,但它确实有效。在</p>
<p>主要:</p>
<pre><code>def Main():
dir_name = input("Enter the destination path: ")
if os.path.isdir(dir_name):
print ("Directory already existed.")
else:
print ("Directory created successfully!")
os.makedirs(dir_name)
choice = input("Would you like to (M)ove or (R)estore?: ")
if choice == 'M':
path = input("Directory of file you want moved: ")
file = input("Name of the file+extension: ")
file_path = path+'/'+file
move(file_path)
print ("Done.")
elif choice == 'R':
with open('quar_id.txt') as f:
quar_id = f.readline()
restore_from_quar(quar_id)
print ("Done.")
else:
print ("No valid option selected, closing...")
</code></pre>
<p>移动:</p>
^{pr2}$
<p>还原:</p>
<pre><code>def restore(quar_id):
os.chdir(dir_name)
myfile = os.listdir(dir_name)
file = str(myfile)
file = file[2:-2]
shutil.move(file,quar_id+'/'+file)
</code></pre>