nums = [1, 4, 3, 2]
print(nums[0:len(nums)/2])
print(nums[0:len(nums)/2])
TypeError: slice indices must be integers or None or have an __index__ method
print(len(nums)/2) 发现是浮点数(刚换的Python3)
把/改为//取整就正常了
nums = [1, 4, 3, 2]
print(nums[0:len(nums)//2])