python - 获取“无”而不是python中的值列表
问题描述
我目前在阿里云上做POC,没有授权分享信息。我是python的初学者。让我考虑一个例子来解决我的问题。
我得到none
的不是值列表,
示例代码:
NumSet={1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet).reverse()
print(NumList)
输出:
None
我错过了什么?
解决方案
list.reverse()
就地反转列表并不返回任何内容(或返回None
)。
NumList = list(NumSet) # convert to list first
NumList.reverse() # reverse in-place
这是正确的做法。
推荐阅读
- r - 如何迭代计算 t 检验的 p 值
- python - Python renom 模块具有相同的函数/成员名称,但标记为不同的颜色
- asp.net - 将复杂对象发布到控制器
- python - Python中的反向标签编码器功能
- python - 保存和打开 chrome URL
- reactjs - 在 webpack 构建期间未将 Favicon 添加到构建文件夹
- vba - 选择文件夹(收件箱)并在移动的电子邮件中执行宏
- r - 删除 RStudio 并重新安装后,无法访问站点
- node.js - MongoParseError: URI 没有主机名、域名和 tld
- sql-server - 列出未连接到的实例下的数据库