Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.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:如果字符串在一行中没有包含7个相同字符的子字符串,则返回True_Python_Python 3.x - Fatal编程技术网

Python:如果字符串在一行中没有包含7个相同字符的子字符串,则返回True

Python:如果字符串在一行中没有包含7个相同字符的子字符串,则返回True,python,python-3.x,Python,Python 3.x,我以前没有遇到过这个问题,所以我被卡住了。我只是不知道在我的“如果”语句中写什么。在这种情况下,我应该使用什么字符串方法 def func(string): if #I just don't know what to put in here: return True else: return False 谢谢你!我们还没有学会在课堂上使用“re”,那么还有其他方法吗?在字符串上迭代,保留最后看到的字符,并增加每个循环的计数,清除是否看到新字符。谢

我以前没有遇到过这个问题,所以我被卡住了。我只是不知道在我的“如果”语句中写什么。在这种情况下,我应该使用什么字符串方法

def func(string):
    if #I just don't know what to put in here:
        return True
    else:
        return False

谢谢你!我们还没有学会在课堂上使用“re”,那么还有其他方法吗?在字符串上迭代,保留最后看到的字符,并增加每个循环的计数,清除是否看到新字符。谢谢!我们还没有学会在类中使用“re”,那么还有其他方法吗?在字符串上迭代,保留最后看到的字符,并增加每个循环的计数,清除是否看到新字符。
return not re.search('(.)\\1{6}', S)