-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_sh.py
More file actions
executable file
·49 lines (34 loc) · 1.29 KB
/
code_sh.py
File metadata and controls
executable file
·49 lines (34 loc) · 1.29 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
#!/Users/erikjensen/Documents/miniconda3/envs/idp/bin/python
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(" TESTING PYTHON ")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
import fileinput
print ("Text to search for:")
textToSearch = input( "> " )
print ("Text to replace it with:")
textToReplace = input( "> " )
print ("File to perform Search-Replace on:")
fileToSearch = input( "> " )
with fileinput.FileInput(fileToSearch, inplace=True, backup='.bak') as file:
for line in file:
print(line.replace(textToSearch, textToReplace), end='')
# mainfile = open('main.cpp','r+') #r+ is a read/append mode, r for read, w for write (erases previous file of same name)
# for line in mainfile:
# print line, # the comma seems to remove the extra space
# #mainfile.write("Hello Silly") #Appends the string to the EOF
# mainfile.close()
# #Same code as above (minus the write())
# with open('main.cpp') as mainfile2:
# for line in mainfile2:
# print line,
# with open('main.cpp') as mainfile3:
# data = mainfile3.readlines()
# for line in data:
# words = line.split()
# print words
# readFile = open('main.cpp','r')
# writeFile = open('main2.cpp','w')
# lines = readFile.readlines()
# for line in lines:
# words = line.split()
# if words == '//IFDEF':