+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2019-07(6)

2019-08(116)

2019-09(98)

2019-10(17)

2019-11(5)

Python 学习笔记 列表 xxx XXX

发布于2020-09-15 21:18     阅读(838)     评论(0)     点赞(16)     收藏(5)


0

1

2

3

4

5

                           Python 学习笔记 列表 xxx XXX 

  1. bicycles = ['trek', 'cannondale', 'redline', 'specialized']
  2. print(bicycles)
  3. print(bicycles[0])
  4. print(bicycles[0].title())
  5. print(bicycles[-1])
  6. names = ['wenwen', 'juanjuan', 'yuyu']
  7. for x in names:
  8. print(x)
  9. for i in range(0, 3):
  10. print(names[i].title() + " hello !")
  11. motorcycles = ['honda', 'yamaha', 'suzuki']
  12. print(motorcycles)
  13. motorcycles[0] = "ducati"
  14. print(motorcycles)
  15. motorcycles.append("honda")
  16. print(motorcycles)
  17. motorcycles.insert(1, 'xchn')
  18. print(motorcycles)
  19. del motorcycles[0]
  20. print(motorcycles)
  21. poped_motorcycle = motorcycles.pop()
  22. print(motorcycles)
  23. print(poped_motorcycle)
  24. motorcycles = ['honda', 'yamaha', 'suzuki']
  25. last_owned = motorcycles.pop()
  26. print("The last motorcycle I owned was a " + last_owned.title() + ".")
  27. motorcycles.remove("yamaha")
  28. print(motorcycles)
  29. xjcs = ['BL', 'HRB', 'BJ']
  30. print(xjcs)
  31. print(xjcs.pop())
  32. xjcs.append("BJ")
  33. for c in xjcs:
  34. print("wh:" + c)
  35. xjcs.insert(0, "TJ")
  36. xjcs.insert(2, "XT")
  37. xjcs.append("JMS")
  38. print(xjcs)
  39. while len(xjcs) != 2:
  40. print("wh: " + xjcs.pop())
  41. for c in xjcs:
  42. print("c: " + c)
  43. i = len(xjcs)
  44. j = 0
  45. while j < i:
  46. print(str(j) + " " + str(i))
  47. del xjcs[0]
  48. j += 1
  49. print("---")
  50. print(xjcs)
  51. print("---")

 

0

1

2

3

4

5

6

7

8



所属网站分类: 技术文章 > 博客

作者:python是我的菜

链接: https://www.pythonheidong.com/blog/article/524562/b70c07ec758ba4f6ea9d/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

16 0
收藏该文
已收藏

评论内容:(最多支持255个字符)