a=re.findall('b',c) error message: TypeError: expected string or buffer

Purpose : I want to select a list of unicode-encoded strings through findall (there are tuples in the list)

Problem: Error [TypeError: expected string or buffer]

Now test:

define a list of tuples

 

 

My previous purpose was to filter the output value after findall again, and execute findall directly, resulting in an error

 

which is:

 

 

Solution:

 

 In the end, I found that it is actually very simple, that is , the text parameter found by findall should be of string type, and the output of findall is a list type, so taking the list to the second findall to find the text parameter will report an error.

list = re.findall(x, string)

 So just convert the list to a string

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326075680&siteId=291194637