+ 2

How do i create a file that will be moved to a folder that is created?

How do i create a folder via. Py and move the file into it via py? Thank u

6th Dec 2019, 2:11 PM
Gamer cat
Gamer cat - avatar
1 ответ
+ 6
You have raised 3 questions: (1) How to create a new file: Create a file object by using the file name. Use file object to write data to new file. Close created file. (2) How to create a folder: You have to import os module, then use mkdir() to create a folder. If a chained range of folders should be created, use makedirs() (3) How to copy a file: You have to import shutil and then use copyfile(), to move a file use move() In any case I would strictly recommend you to read the python docs because there is also a downside and risk of deleting files or directories !!!!
6th Dec 2019, 6:49 PM
Lothar
Lothar - avatar