【Python】Learn Python the hard way, ex38 列表操作

ten_things = "Apples Oranges Crows Telephone Light Sugar"

print "Wait there's not 10  things in that list, let's fix that."

stuff = ten_things.split(' ')
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"]

while len(stuff) != 10:
    next_one = more_stuff.pop()
    print "Adding: ", next_one
    stuff.append(next_one)
    print "There's %d items now." %len(stuff)
    
print "There we go: ", stuff

print "Let's do some things with stuff."

print stuff[1]
print stuff[-1] #whoa! fancy
print stuff.pop()
print " ".join(stuff) # what? cool!
print '#'.join(stuff[3:5])  #supper stellar!

'''
Test Reslut:

Wait there's not 10  things in that list, let's fix that.
Adding:  Boy
There's 7 items now.
Adding:  Girl
There's 8 items now.
Adding:  Banana
There's 9 items now.
Adding:  Corn
There's 10 items now.
There we go:  ['Apples', 'Oranges', 'Crows', 'Telephone', 'Light', 'Sugar', 'Boy', 'Girl', 'Banana', 'Corn']
Let's do some things with stuff.
Oranges
Corn
Corn
Apples Oranges Crows Telephone Light Sugar Boy Girl Banana
Telephone#Light
'''


最喜欢Python两点,list,re


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"Learn Python the Hard Way" 是一本非常受欢迎的Python编程入门教材,由Zed Shaw编著。虽然很多人推荐这本书,但是可能有人会想要获取中文版的PDF。 实际上,"Learn Python the Hard Way" 的官方版本只有英文版,目前没有官方中文翻译。然而,你仍然可以通过互联网上的其他资源找到非官方的中文翻译版本。在很多技术论坛和编程社区上,都有Python爱好者提供自己的中文翻译版本,一些电子书资源网站上也有非官方的中文PDF版本。 要找到中文翻译版,你可以在搜索引擎中输入相关关键词,比如 "learn python the hard way 中文pdf" 或者 "learn python the hard way 中文翻译"。在搜索结果中,你可能会找到一些免费的资源供你下载或在线阅读。此外,还有一些网站提供付费的中文翻译版本,你可以根据自己的需求决定是否购买。 无论你选择哪种方式,记得要确认翻译版本的质量和真实性。可以通过查看评论、评级或者与其他Python学习者交流来了解其他人对于该版本的评价。另外,虽然中文翻译版本对于初学者会有一定帮助,但如果你有能力阅读英文,最好还是参考官方英文版来学习,以避免因为翻译的不准确而导致的误解或困惑。 总而言之,虽然"Learn Python the Hard Way"的官方版本只有英文版,但你可以通过互联网查找一些非官方的中文翻译版本。希望你能够找到一本合适的中文翻译版本,顺利学习Python编程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值