设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 10058|回复: 0
打印 上一主题 下一主题

.pop(-1)中的-1怎么理解?

[复制链接]

5

主题

0

好友

69

积分

注册会员

Rank: 2

跳转到指定楼层
楼主
发表于 2013-11-11 09:02:22 |显示全部楼层 |倒序浏览
def print_last_word(words):    """Prints the last word after popping it off."""    word = words.pop(-1)    print word https://learn-python-the-hard-way-zh_cn-translation.readthedocs.org/en/latest/ex25.html
如图所示,为什么输出的结果是删除最后一个单词,-1怎么理解?

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-18 17:20 , Processed in 0.015438 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部