Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如果有重复项,请检查4个字符串_Python_Python 2.7 - Fatal编程技术网

Python 如果有重复项,请检查4个字符串

Python 如果有重复项,请检查4个字符串,python,python-2.7,Python,Python 2.7,s1、s2、s3、s4有一个字符串作为内容 我想做这样的事情 if one or more is the same s1, s2, s3 or s4: print error else print s1, s2, s3, s4 您可以使用一套: if len(set([s1, s2, s3, s4])) != 4: pass # not all unique 如果要检查所有字符串是否不同: 4 == len(set([s1, s2, s3, s4]))

s1、s2、s3、s4有一个字符串作为内容

我想做这样的事情

if one or more is the same s1, s2, s3 or s4:
    print error
else
    print s1, s2, s3, s4
您可以使用一套:

if len(set([s1, s2, s3, s4])) != 4:
    pass # not all unique

如果要检查所有字符串是否不同:

4 == len(set([s1, s2, s3, s4]))