-
Notifications
You must be signed in to change notification settings - Fork 17
/
Creating.py
27 lines (22 loc) · 1.02 KB
/
Creating.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Creating a new text file.
path = "assets/Random.txt" # Remember to enter the file name you want to create.
print("Creating a file at assets/File Handling with the name Random.txt")
file = open(path, "w+")
def doc():
"""
Modes by which you can open files in python :
Files are opened using the open function in python, that takes the name and mode as argument.
Different modes :
1) r : Used to open a file for reading.
2) w : For writing. If file already exists, it will delete all the pre-existing data.
3) x : Used to open a file for exclusive creation. Failing if the file already exists.
4) a : Used for writing and apppending to the file if it already exists.
5) b : binary mode.
6) t : text mode.
7) +r : Open a file for updating. Reading or Updating.
8) w+ : Used to create a text file or any other types.
Modes for other files(CSV,JSON):
The exact same procedure for other files. Just change .txt to .Json or .csv
"""
print(doc.__doc__)
input("Press Enter key to exit ")