Python sort后赋值 操做陷阱

x=[1,4,2,0]  

# 错误的方式,由于sort没有返回值
y=x.sort()    
type (y)     #NoneType  

#正确的方式
x.sort()
y=x[:]
相关文章
相关标签/搜索