Python:错误'list'对象没有'sorted'属性

2024-05-17 04:04:10 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码:

#这是一个有关旅行的程序
place=['北京天安门','西安兵马俑','香港游乐园','日本秋叶原']
print(place)
print(sorted(place))
print(place)

place.sorted(reverse=true)
print(place)

当我运行代码时,会发生错误。

place.sorted(reverse=true)

或者

sorted(place)

使用第二种方法,我如何给出(reverse=true)


Tags: 方法代码程序true错误placereversesorted