Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.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 TypeError:+;的操作数类型不受支持:'_sre.sre#u Match';和'_sre.sre#u Match';_Python - Fatal编程技术网

Python TypeError:+;的操作数类型不受支持:'_sre.sre#u Match';和'_sre.sre#u Match';

Python TypeError:+;的操作数类型不受支持:'_sre.sre#u Match';和'_sre.sre#u Match';,python,Python,我有此代码,但我不明白为什么会出现此错误: a= name+pw+salt TypeError: unsupported operand type(s) for +: '_sre.SRE_Match' and '_sre.SRE_Match' 剧本 class MainHandler(Handler): def make_salt(self): return ''.join(random.choice(string.ascii_letters) for x in ra

我有此代码,但我不明白为什么会出现此错误:

a= name+pw+salt
TypeError: unsupported operand type(s) for +: '_sre.SRE_Match' and '_sre.SRE_Match'
剧本

class MainHandler(Handler):

    def make_salt(self):
        return ''.join(random.choice(string.ascii_letters) for x in range(5))

    def make_pw_hash(self, name, pw):
        salt = self.make_salt()    
        a= name+pw+salt //problem here

        h = hashlib.sha256(a.encode("UTF8")).hexdigest()
        return '%s|%s' % (h, salt)


    def post(self):
        store_hash_and_salt = self.make_pw_hash("José", "somePass")  
        print (store_hash_and_salt)
问题不在那里。早些时候,您将重新匹配结果传递给它,而不是使用
group()
方法从中获取字符串


(另外,返回字符串的格式不正确,但这不是这里的错误。)

他是对的。在某个地方,您导入了重新初始化的对象,并将其称为make_pw_hash