Python sort後賦值 操做陷阱

x=[1,4,2,0]  

# 錯誤的方式,由於sort沒有返回值
y=x.sort()    
type (y)     #NoneType  

#正確的方式
x.sort()
y=x[:]
相關文章
相關標籤/搜索