0
how to create file in python? ?
10 Respostas
+ 6
open function in write mode creates a new file (if it doesn't already exist.) Then you have an empty file and you can do with it whatever you want...
code:
file = open ('namefile.txt', "w")
+ 2
if you have nothing to say, please be quiet. here there are people who want to learn python. post only serious answers. thank you
- 2
To create a few in python your u have to use the open command in write mode which creates a file with the same name you gave to "open" in y the working directory/folder you're in. After using open to do this you can write the commands you wish to write in the file and close/save it. So
file = open("my file.txt", mode ="w") # ones write mode in "my file.txt")
print(" hello world!\n hi there.") # writes two lines in the file
file.close() # closes the file
- 3
(Hello,world)
- 3
sry I didn't understand
- 3
you use smartphone or PC?
- 4
filename.py
- 4
sry, i understand you, but i cant create file in pc
- 5
not that file...
a text file...
- 5
pc