Python3基础 str while+iter+next 字符串的遍历
- Python : 3.7.0
- OS : Ubuntu 18.04.1 LTS
- IDE : PyCharm 2018.2.4
- Conda : 4.5.11
- typesetting : Markdown
code
"""
@Author : 行初心
@Date : 18-9-23
@Blog : www.cnblogs.com/xingchuxin
@Gitee : gitee.com/zhichengjiu
"""
def main():
my_str = 'xingchuxin'
# for循环
for each in my_str:
print(each, end=" ")
print()
# while配合迭代器实现字符串的遍历
ite = iter(my_str)
while True:
try:
each = next(ite)
except StopIteration: # 为什么是StopIteration
break
print(each, end=" ")
if __name__ == '__main__':
main()
result
/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/StrTest/demo.py
x i n g c h u x i n
x i n g c h u x i n
Process finished with exit code 0
resource
- [文档] docs.python.org/3
- [规范] www.python.org/dev/peps/pep-0008
- [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
- [源码] www.python.org/downloads/source
- [ PEP ] www.python.org/dev/peps
- [平台] www.cnblogs.com
- [平台] gitee.com
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。
Python3基础 str while+iter+next 字符串的遍历的更多相关文章
- Python3基础 str capitalize 返回新字符串,第一个字母大写
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str partition 以参数字符串切分字符串,只切分为三部分
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str count 获得子字符串出现的次数
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str *运算 重复拼接字符串
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础02(列表和字符串处理)
str = 'Runoob'# 输出字符串print(str) # 输出第一个到倒数第二个的所有字符print(str[0:-1]) # 输出字符串第一个字符print(str[0]) # 输出从第三 ...
- Python3基础 str 通过拆分字符串与插入新的内容形成新的字符串
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str casefold 返回全是小写字母的新字符串
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str : 对字符串进行切片
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- Python3基础 str split 用指定的字符将字符串分割
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- ONLYstore_name+AdWord
情景描述ONLYstore_name+AdWord 基础表数据表 BASE_TABLEAdWord food drink1w1 1f1 1d12w2 2f_ 2d_3w1 ...
- wf-pagination-javascript 分页
1 <?php isset($_REQUEST['form_single_page_num']) && !empty($_REQUEST['form_single_page_nu ...
- msc文件
MSC微软管理控制台(Microsoft Management Control)文件.可以点击开始/运行,然后输入下列文件名就可以打开相应的控制窗口. 除第三个文件外,其他均在C:\WINDOWS\s ...
- 指定多个pip源
https://blog.csdn.net/liujiong63/article/details/78795015 Linux环境下创建pip配置文件: vim .pip/pip.conf [glob ...
- Count the Colors---zoj1610线段树
题目链接 题意: 求每种颜色有几段线段: 模拟数组: #include<stdio.h> #include<iostream> #include<algorithm> ...
- CentOS代理设置
1.全局的代理设置: vi /etc/profile 添加下面内容 http_proxy = http://username:password@yourproxy:8080/ftp_proxy = h ...
- 正则验证ip
用python爬获取这样一条数据: <td class="ip" id="ip"><p style="display: none;& ...
- linux 安装mysql yum方式
centos 6 #二进制rpm包安装 yum -y install mysql-server mysql centos7 mariadb和mysql一样的 只是一个分支 防止 mysql 被Orac ...
- 怎样知道 CPU 是否支持虚拟化技术(VT) | Linux 中国
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/79832475 wx_fmt=png&a ...
- Python随机数生成方法
假设你对在Python生成随机数与random模块中最经常使用的几个函数的关系与不懂之处.以下的文章就是对Python生成随机数与random模块中最经常使用的几个函数的关系,希望你会有所收获,以下就 ...