Tag Archives: slice indices must be integers or None or have

How to Solve Python Error: slice indices must be integers or None or have

My code:

The content is treated as a string

content[len(content)/2:len(content)/2+5]

Error:

TypeError: slice indices must be integers or None or have an __ index__ method

Looking through a lot of data, we find that Python may be converted to floating-point number when dividing. You need to change the “/” in it to “/ /” to run it