TypeError: 'dict_keys' object does not support indexing

后端 未结 5 1416
Happy的楠姐
Happy的楠姐 2020-11-27 13:21
def shuffle(self, x, random=None, int=int):
    \"\"\"x, random=random.random -> shuffle list x in place; return None.

    Optional arg random is a 0-argument fu         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 14:12

    In Python 2 dict.keys() return a list, whereas in Python 3 it returns a generator.

    You could only iterate over it's values else you may have to explicitly convert it to a list i.e. pass it to a list function.

提交回复
热议问题