Python - Descriptor 'split' requires a 'str' object but received a 'unicode'

后端 未结 3 2145
小鲜肉
小鲜肉 2021-02-20 14:26

Erm, I have ready-to-use code, and I\'m sure it really works, but I get the following error:

TypeError: descriptor \'split\' requires a \'str\' object but

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 14:49

    The problem is that str.split is a method of the str class, but is being called for an object of the unicode class. Call the method directly with ipSplit = self.serverVars[0].split('.') to have it work for anything (including str and unicode) with a split method.

提交回复
热议问题