TypeError: slice indices must be integers or None or have an index method编程python时报错 错误如下: 解决方法: 只需要用int()对索引 len(s) / 2等进行强制类型转换,如下 这样就OK啦!