search

Home  >  Q&A  >  body text

使用python怎么实现查找两个字符串中相同字符?

使用python怎么实现查找两个字符串中相同字符?

大神,求带!大神,求带!2857 days ago1232

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:00:36

    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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-02-04 11:07:47

    具体示例代码如下:

    seq1 = "spam" 
    seq2 = "scam" 
    res = []
    for x in seq1:
      if x in seq2:
        res.append(x)
    print res

    输出结果如下:

    ['s', 'a', 'm']


    reply
    0
  • Cancelreply