题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'tianyi'
__date__ = '2024/3/23 20:04 '
__file__ = 'HW_HJ81.py'
import sys
# 1. 读取输入
need_match = ""
n = 0
for i in sys.stdin:
# 2. 按空格分割
n+=1
total = 0
if n%2 == 0:
String1 = i.rstrip()
for i in need_match:
if i not in String1:
print("false")
break
else:
total += 1
if total == len(need_match):
print("true")
else:
need_match = i.rstrip()
字符串可以遍历,可以使用 not in逻辑。