-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText File.py
57 lines (33 loc) · 859 Bytes
/
Text File.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
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
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
# In[13]:
df=pd.read_csv('C:\\Users\\Randrita s\\Downloads\\cow1.txt')
# In[34]:
with open("C:\\Users\\Randrita s\\Downloads\\cow1.txt") as f:
content = f.readlines()
content = [x.strip() for x in content]
#print(content)
pattern = input('Enter word you want to change:')
# empty string
replace = input('Enter the new word:')
for i in content:
#if i==pattern:
new_string= re.sub(pattern,replace,i)
print(new_string)
# In[103]:
with open("C:\\Users\\Randrita s\\Downloads\\cow1.txt") as f:
strs = f.readlines()
#print(content)
#a=input('Enter the word : ')
a=input()
#x=r'{}'.format(a)
for i in strs:
re.search(r'',i)
match = re.search(r'\b{}\b'.format(a),i)
if match:
print ("Found")
else:
print ("Not Found")
# In[ ]: