python第20篇之--元组的使用

来源:互联网 发布:疯狂的美工京东注册码 编辑:程序博客网 时间:2024/05/14 08:03
#!/usr/bin/pythonzoo = ('python','elephant','penguin')print('Number of animals in the zoo os',len(zoo))new_zoo = ('monkey','camel',zoo)print('Number of the cages in the new zoo is',len(new_zoo))print('All animals in new zoo are',new_zoo)print('Animals brought from old zoo are:',new_zoo[2])print('Last anials brought from old zoo is',new_zoo[2][2])print('Number of animals in the new zoo is',len(new_zoo)-1+len(new_zoo[2]))

结果:

~/Note/python # ./2using_tutle.py Number of animals in the zoo os 3Number of the cages in the new zoo is 3All animals in new zoo are ('monkey', 'camel', ('python', 'elephant', 'penguin'))Animals brought from old zoo are: ('python', 'elephant', 'penguin')Last anials brought from old zoo is penguinNumber of animals in the new zoo is 5


原创粉丝点击