How do i define a funcition in python that creates files? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i define a funcition in python that creates files?

I have to use files to save data about users and I thought that the easiest way to do this in a big programme was by defining a function. Is it alright to do this? Can someone help me?

5th Jan 2020, 12:40 AM
Olívia
Olívia - avatar
3 Answers
5th Jan 2020, 1:06 AM
HonFu
HonFu - avatar
+ 3
Here is a short tutorial for basic file operations: https://code.sololearn.com/cESZeFlM1cRR/?ref=app
5th Jan 2020, 6:45 AM
Lothar
Lothar - avatar
+ 1
Maybe just open("file.extension", "r"|"w")
5th Jan 2020, 4:45 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar