-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday13.py
More file actions
61 lines (37 loc) · 2.03 KB
/
day13.py
File metadata and controls
61 lines (37 loc) · 2.03 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# https://github.com/rohitsharma8433
# File handling in Python is a crucial aspect of working with data, as it allows you to read from and write to files. Python provides built-in functions and libraries for working with files, making it relatively easy to perform tasks such as reading text from a file, writing data to a file, and more.
# Here are the fundamental operations for file handling in Python:
# Opening a File:
# You can use the open() function to open a file. It takes two arguments - the file name and the mode in which you want to open the file (read, write, append, etc.). The most common modes are:
# 'r': Read (default)
# 'w': Write (truncate the file if it already exists)
# 'a': Append (create a new file or append to an existing one)
# 'x': it is use to crteate file
# creating file through python
# f=open('data.txt','x')
# write into file using write function
# f=open('data.txt','w')
# f.write("ham ja rhe hai ghumne ")
# f.close()
# Append into file
# f=open('data.txt','a')
# f.write("hum ke aa gye ")
# f.close()
# read from file
# f=open('data.txt','r')
# x=f.read()
# print(x)
# f.close()
# inserting multiline in file
f=open('data.txt','w')
f.write(""" # https://github.com/rohitsharma8433
# File handling in Python is a crucial aspect of working with data, as it allows you to read from and write to files. Python provides built-in functions and libraries for working with files, making it relatively easy to perform tasks such as reading text from a file, writing data to a file, and more.
# Here are the fundamental operations for file handling in Python:
# Opening a File:
# You can use the open() function to open a file. It takes two arguments - the file name and the mode in which you want to open the file (read, write, append, etc.). The most common modes are:
# 'r': Read (default)
# 'w': Write (truncate the file if it already exists)
# 'a': Append (create a new file or append to an existing one)
# 'x': it is use to crteate file
""")
f.close()