Love丶FFC's Blog
给出一个字符串和多行文字,在这些文字中找到字符串出现的那些行。你的程序还需支持大小写敏感选项:当选项打开时,表示同一个字母的大写和小写看作不同的字符;当选项关闭时,表示同一个字母的大写和小写看作相同的字符。
输入的第一行包含一个字符串S,由大小写英文字母组成。
第二行包含一个数字,表示大小写敏感的选项,当数字为0时表示大小写不敏感,当数字为1时表示大小写敏感。
第三行包含一个整数n,表示给出的文字的行数。
接下来n行,每行包含一个字符串,字符串由大小写英文字母组成,不含空格和其他字符。
输出多行,每行包含一个字符串,按出现的顺序依次给出那些包含了字符串S的行。
Hello
1
5
HelloWorld
HiHiHelloHiHi
GrepIsAGreatTool
HELLO
HELLOisNOTHello
HelloWorld
HiHiHelloHiHi
HELLOisNOTHello
在上面的样例中,第四个字符串虽然也是Hello,但是大小写不正确。如果将输入的第二行改为0,则第四个字符串应该输出。
1<=n<=100,每个字符串的长度不超过100。
1.使用Python中的lower()方法和in关键字即可
2.对大小写是否敏感的情况分别进行处理
3.注意转为小写的时候不要使用赋值,否则最终输出的字符串是错误的
Sourcestr = input() # 输入寻找的字符串 CaseSense = int(input()) # 输入大小写是否敏感,0为不敏感,1为敏感 NOS = int(input()) # 输入匹配的字符串的个数 for i in range(NOS): Targetstr = input() # 输入匹配的字符串 if CaseSense == 0: # 大小写不敏感 if Sourcestr.lower() in Targetstr.lower(): # 都使用小写来比较 print(Targetstr) else: # 大小写敏感 if Sourcestr in Targetstr: print(Targetstr)
cheap real jordans
Read reviews and was a little hesitant since I had already inputted my order. or possibly a but thank god, I had no issues. love the received item in a timely matter, they are in new condition. you ultimately choose so happy I made the purchase. Will be definitely be purchasing again.
cheap real jordans https://www.cheapsneakeronline.com/
cheap jordans for sale
Read reviews and was a little hesitant since I had already inputted my order. or even but thank god, I had no issues. like the received item in a timely matter, they are in new condition. an invaluable so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans for sale https://www.realjordansretro.com/
Gealpaste
levitra generique arnaque Toxicities, which occurred in 22 of patients, included lethargy, peripheral edema, and hot flashes
intuido
can i buy cialis without a prescription Lenograstim Lenograstim is a substance that stimulates the production of a type of white blood cell from the bone marrow, known as neutrophils
fqTkTxv
buy cialis on line Crump M, Goss PE, Prince M, Girouard C