I have Excel files with data that I need to summarize so I've created a list called a_master
that contains all of this info (using xlrd).
What I need to do now is search for a specific word for example "cloud"
and if it finds the word, to print out the sentence that contains that word. It doesn't seem to work though.
It outputs everything that it finds after the searchable word.
for line in str(a_master):
if "cloud" in line:
print line
If a_master
is a list as you said, probably this is what you want:
for line in a_master:
str_line = str(line)
if "cloud" in str_line:
print str_line
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.