•        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 字符串的遍历的更多相关文章

  1. Python3基础 str capitalize 返回新字符串,第一个字母大写

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Python3基础 str partition 以参数字符串切分字符串,只切分为三部分

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. Python3基础 str count 获得子字符串出现的次数

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  4. Python3基础 str *运算 重复拼接字符串

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  5. Python3基础02(列表和字符串处理)

    str = 'Runoob'# 输出字符串print(str) # 输出第一个到倒数第二个的所有字符print(str[0:-1]) # 输出字符串第一个字符print(str[0]) # 输出从第三 ...

  6. Python3基础 str 通过拆分字符串与插入新的内容形成新的字符串

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. Python3基础 str casefold 返回全是小写字母的新字符串

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  8. Python3基础 str : 对字符串进行切片

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  9. Python3基础 str split 用指定的字符将字符串分割

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

随机推荐

  1. 币安Binance API

    本文介绍币安Binance API General API Information The base endpoint is: https://api.binance.com All endpoint ...

  2. flask 小入门知识点 2018.12.19

    今天听得一脸懵逼,主要因为自己英文底子太差了 不耽误时间了,少总结下,开始复习... 代码: # -*- encoding: utf-8 -*- # 导入重定向模块 , url_for简易寻址跳转,j ...

  3. Charles maplocal 时中文显示乱码问题

    用Charles对request进行Map Local后,app上看返回的中文是乱码? 是Map Local的文件编码有问题?是Charles设置有问题?是电脑环境有问题?哈哈,都不是 你是Andro ...

  4. html+css小总结

    html+css小总结 1.块级元素 <div> <h1> <hr /> <p> <pre> <ol> <ul> & ...

  5. js屏蔽f12键

    <script>            $(document).keydown(function(e) {                 if (e.keyCode == 123) {/ ...

  6. 前端 html input标签 placeholder属性 标签上显示内容

    前端 html  input标签 的placeholder属性  标签上显示内容 <!DOCTYPE html> <html lang="en"> < ...

  7. hashcode()和equals()的作用、区别、联系

        介绍一. hashCode()方法和equal()方法的作用其实一样,在Java里都是用来对比两个对象是否相等一致,那么equal()既然已经能实现对比的功能了,为什么还要hashCode() ...

  8. git merge和git rebase

    转载于http://blog.csdn.net/wh_19910525/article/details/7554489 git merge是用来合并两个分支的. git merge b # 将b分支合 ...

  9. PAT 1040 Longest Symmetric String[dp][难]

    1040 Longest Symmetric String (25)(25 分) Given a string, you are supposed to output the length of th ...

  10. Git+Jenkins+FileGee 发布php应用

    Git:做版本控制,回滚版本(coding.net) Jenkins:代码下载,提供webhook url FileGee:同步代码(一个国产同步.备份软件非常强大,而且便宜企业版只要498) jen ...