File tree Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ Cargo.lock
3
3
4
4
** /* .rs.bk
5
5
.cargo
6
+ .py
6
7
7
8
# node configuration files
8
9
/config /
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+ directory = os .getcwd ()
4
+ for filename in os .listdir (directory ):
5
+ if filename .endswith (".rs" ) or filename .endswith (".png" ):
6
+ print (os .path .join (directory , filename ))
7
+
8
+ #remove last line from a text line in python
9
+ fd = open (filename ,"r" )
10
+ d = fd .read ()
11
+ fd .close ()
12
+ m = d .split ("\n " )
13
+ s = "\n " .join (m [:- 1 ])
14
+ fd = open (filename ,"w+" )
15
+ for i in range (len (s )):
16
+ fd .write (s [i ])
17
+ fd .close ()
18
+
19
+ else :
20
+ continue
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+ directory = os .getcwd ()
4
+ for filename in os .listdir (directory ):
5
+ if filename .endswith (".rs" ) or filename .endswith (".png" ):
6
+ print (os .path .join (directory , filename ))
7
+
8
+ with open (filename , "a+" ) as file_object :
9
+ # Move read cursor to the start of file.
10
+ file_object .seek (0 )
11
+ # If file is not empty then append '\n'
12
+ data = file_object .read (100 )
13
+ if len (data ) > 0 :
14
+ file_object .write ("\n " )
15
+ # Append text at the end of file
16
+ #file_object.write("hello hi")
17
+
18
+ else :
19
+ continue
Original file line number Diff line number Diff line change 1
- 1
You can’t perform that action at this time.
0 commit comments