鱼C论坛

 找回密码
 立即注册
查看: 2073|回复: 3

为什么打印的值 不是全列表 而是一个不相干的值

[复制链接]
发表于 2020-1-21 14:27:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
Chinese_new_year_dinner = ['自己','mother','father','grandmother','sisther']
>>> Chinese_new_year_dinner.append('yaoba')
>>> print(Chinese_new_year_dinner)
['自己', 'mother', 'father', 'grandmother', 'sisther', 'yaoba']
>>> print(Chinese_new_year_dinner.pop(-2))
sisther
>>> print(Chinese_new_year_dinner)
['自己', 'mother', 'father', 'grandmother', 'yaoba']
>>> New_chinese_new_year_dinner = Chinese_new_year_dinner.append('yaoma')
>>> print(New_chinese_new_year_dinner)
None
为什么最后这个我赋值的最后打印的不是全列表是一个None呢  一直搞不懂
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-1-21 14:35:41 | 显示全部楼层
这一句出了问题:

  1. New_chinese_new_year_dinner = Chinese_new_year_dinner.append('yaoma')
复制代码


应该先执行 Chinese_new_year_dinner.append('yaoma'),再执行 New_chinese_new_year_dinner = Chinese_new_year_dinner
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-1-21 14:35:41 From FishC Mobile | 显示全部楼层
返回值不是列表
另,变量名太长,
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-1-21 15:54:51 | 显示全部楼层
append是直接修改列表,没有返回值,即x = list1.append('abc')时x没有值为None
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-21 21:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表