使用python怎么实现查找两个字符串中相同字符?
How to use python to find the same characters in two strings? -PHP Chinese website Q&A-How to use python to find the same characters in two strings? -PHP Chinese website Q&A
Let’s take a look and learn.
具体示例代码如下:
seq1 = "spam" seq2 = "scam" res = [] for x in seq1: if x in seq2: res.append(x) print res
输出结果如下:
['s', 'a', 'm']
How to use python to find the same characters in two strings? -PHP Chinese website Q&A-How to use python to find the same characters in two strings? -PHP Chinese website Q&A
Let’s take a look and learn.
具体示例代码如下:
输出结果如下: