Python Basics Move a file to a different directory

preview_player
Показать описание
Learn how to copy and save a file to a different directory using the open function from python programming

twitter: @python_basics
Рекомендации по теме
Комментарии
Автор

I did a little extra :
n_file = input('Enter file name: ')
chang = input('Rename file? y/n: ')
if chang == 'y':
c_file = input('Enter file name: ')
else:
c_file = n_file

f_path = input('Enter directory: ')
print(f_path) # checking my work

if f_path[-1] != '\\':
f_path += '\\'
print(f_path) # checking pythons work

with open(n_file, 'r') as file:
text = file.read()
with open(f_path + c_file, 'w') as file:
file.write(text)

blueicewolfgmail
join shbcf.ru