wrote a code that would generate various folders to me. It is assumed that the code will create a folder, and within her file. Then, open the file and record content in it:
filename= airline ["IATA"] + '/index.php' if not os.path.Exists (os.path.dirname (FileName)): OS.Makedirs (FileName) With Open (FileName, "W") AS F: F.Write ("< ? PHP Include ('generator.php'); ? ≫ ")
In the end, the folder should turn out
but instead of creating a file I have a nested folder called
. How do I do so that the file is created in the newly created folder and write down in it?
Answer # 1
Makedirs.You need to pass the folder:
filename= airline ["IATA"] + '/index.php' if not os.path.Exists (os.path.dirname (FileName)): dir_name= os.path.dirname (FileName) OS.Makedirs (Dir_Name) With Open (FileName, "W") AS F: F.Write ("< ? PHP Include ('generator.php'); ? ≫ ")
- python : How to Number List Elements?
- python : PYQT5 Opening /closing window in the trigger
- python : It is necessary to highlight elements from the dictionary.
- python : Problem with sample and json module
- python : lambda with for not working
- How to run your Python3 script on different OS?
- How in Python + Selenium WebDriver to open a new tab in the already open browser?
- python : How to make sending a message to ALS to all users?
- python : It is necessary to create an application for determining the disconnection of a supply based on Polyglot
- SQLite Python3 -search in the database how to fix TypeError