Open IanFan opened 5 years ago
用这个[]赋值有点深拷贝的意思
play_data = list(play_data)[:] vs play_data = list(play_data) python2.7: list(play_data)[:] is fine python3.6: list(play_data)[:] is []
It's nothing to do with the [:] operator. play_data is an zip, which returns an iterator in Python 3. You can only iterate over an iterator once. So you get [] if you call list(play_data) the second time. For example:
aa = zip([1,2,3],[3,4,5])
list(aa)
>>> [(1, 3), (2, 4), (3, 5)]
list(aa)
>>> []
play_data = list(play_data)[:] vs play_data = list(play_data) python2.7: list(play_data)[:] is fine python3.6: list(play_data)[:] is []