14

python字符串遍历方式-测试生财的博客

 3 years ago
source link: https://blog.51cto.com/14900374/2561198
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
前言很多面试题里都有关于字符串相关的算法,这里简单总结一下python的字符串遍历。遍历方式python的字符串遍历有三种方式:1. 下标法2. for in3. iter内置函数4. enumerate其中下标法和enumerate适合需要判断后续字符的场景,比如循环到下标index出,要求判断index+1的字符这种。最典型的题目就是语法解析器,判断"(())"这种成对的括号的算法。"for

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK