Giả sử có 2 file, 1 file *.txt, 1 file *.py
Data.txt chứa nội dung:
question
doing
exhaustion
going
cat
digestion
dog
suggestion
combustion
playing
indigestion
bastion
...
XuLy.py
1
2
3
4
| for line in open("Data.txt"):
for word in line.split():
if not(word.endswith("ion")) and not(word.endswith("ing")):
print word
|
Kết quả:
cat
dog