0

how to create file in python? ?

1st Oct 2016, 3:12 PM
Nithish Dongre
Nithish Dongre - avatar
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")
1st Oct 2016, 3:45 PM
Amarie
+ 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
8th Oct 2016, 9:46 PM
Paolo Di Paolo
Paolo Di Paolo - avatar
- 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
2nd Oct 2016, 10:39 AM
Bob
- 3
(Hello,world)
1st Oct 2016, 3:16 PM
Тимур Хасанов
Тимур Хасанов - avatar
- 3
sry I didn't understand
1st Oct 2016, 3:19 PM
Nithish Dongre
Nithish Dongre - avatar
- 3
you use smartphone or PC?
1st Oct 2016, 3:21 PM
Тимур Хасанов
Тимур Хасанов - avatar
- 4
filename.py
1st Oct 2016, 3:13 PM
Тимур Хасанов
Тимур Хасанов - avatar
- 4
sry, i understand you, but i cant create file in pc
1st Oct 2016, 3:33 PM
Тимур Хасанов
Тимур Хасанов - avatar
- 5
not that file... a text file...
1st Oct 2016, 3:15 PM
Nithish Dongre
Nithish Dongre - avatar
- 5
pc
1st Oct 2016, 3:22 PM
Nithish Dongre
Nithish Dongre - avatar