Answer the question
In order to leave comments, you need to log in
How to move a file using Python?
I tried using the os library:
os.rename('D:\\OneDrive\\Python\\PYTHON_LECTURES\\lecture3.py', 'D:\\OneDrive\\Python\\PYTHON_LECTURES\\small\\lecture3.py')
shutil.copyfile(r'D:\OneDrive\Python\PYTHON_LECTURES\test.py', r'D:\OneDrive\Python\PYTHON_LECTURES\test\test.py')
Answer the question
In order to leave comments, you need to log in
the problem is in
dirname = os.path.split(filename)[0]
if not os.path.exists(dirname):
os.makedirs(dirname)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question