Python之for循环
来源:互联网 发布:二代防火墙 知乎 编辑:程序博客网 时间:2024/05/23 21:15
#Python的for可以遍历 a list or a string#Measure some stringswords = ['happy', 'smile', 'sunshine']for word in words : print(word, len(word))"""result: happy 5 smile 5 sunshine 8"""""" 在for循环遍历的时候,可以加入条件遍历,也可以随即改变集合,比如向集合中copy元素, words[:]创建一个无限长度的集合words"""for word in words[:]: if len(word) >6 : words.insert(0,word)print(words)"""result: ['sunshine', 'happy', 'smile', 'sunshine']"""
阅读全文
0 0
- Python之for循环
- python之for循环详解
- Python探索之路(四)---for循环嵌套for循环
- python学习笔记之-for循环
- Python for循环之查找下一个记录
- Python探索之路(三)---for循环
- Python之if,for和while循环
- Python基础篇之for循环
- Python的for循环
- python for 循环
- Python for循环
- python中的for循环
- python迭代器 for循环
- Python for 循环语句
- python中的for循环
- python中的for循环
- Python--for循环
- python-for循环
- PAT1005. Spell It Right (20)
- 网易页面设计稿参考
- response和request方法
- applicationcontext.xml中sessionFactory、transactionManager等自动生成
- poj 2411 Mondriaan's Dream (状态压缩dp)
- Python之for循环
- AM335X下Linux驱动 spi 收不到消息
- 算法训练 结点选择 树形DP
- 在以(后继)线索二叉树为储存结构的二叉排序树中删除关键字为x的数据元素
- chrome 不能访问更新服务器
- 在ubuntu下使用wordpress搭建博客
- Java初学
- JSP入门及idea上配置tomcat
- 7.7用欧几里得算法求最大公约数(2)