File tree Expand file tree Collapse file tree 1 file changed +99
-0
lines changed Expand file tree Collapse file tree 1 file changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+
3
+ '''poem = '''\
4
+ Programming is fun when the work is done
5
+ if you wanna make your work also fun:
6
+ use Python:
7
+
8
+
9
+ #Open for 'w'riting
10
+ f = open('poem.txt', 'w')
11
+ #Write text to file
12
+ f.write(poem)
13
+ #Close the file
14
+ f.close()
15
+
16
+ #If no mode is specified,
17
+ #'r'ead mode is assumed by default
18
+ f = open('poem.txt')
19
+ while True:
20
+ line = f.readline()
21
+ #Zero length indicates EOF
22
+ if len(line) == 0:
23
+ break
24
+ #The line already has newline
25
+ # at the end of each line
26
+ # since it is reading from a file.
27
+ print(line, end='')
28
+
29
+ #close the file
30
+ f.close()"""
31
+
32
+
33
+ #PICKLE
34
+
35
+ #Python provides a standard module called pickle which you can use to store any plain Python object in a file and then get it back later.
36
+ #This is called storing object persistently.
37
+
38
+ '''import pickle
39
+
40
+ #The name of the file where we will store the object
41
+ shoplistfile = 'shoplist.data'
42
+ # The list of things to buy
43
+ shoplist = ['apple', 'mango', 'carrot']
44
+
45
+ #Write to the file
46
+ f = open(shoplistfile, 'wb')
47
+ #Dump the object to a file
48
+ pickle.dump(shoplist, f)
49
+ f.close()
50
+
51
+ # Destroy the shoplist variable
52
+ del shoplist
53
+
54
+ # Read back from the storage
55
+ f = open(shoplistfile, 'rb')
56
+ # Load the object from the file
57
+ storedlist = pickle.load(f)
58
+ print(storedlist)'''
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
You can’t perform that action at this time.
0 commit comments