我可以简单地++一个字符?这样做的有效方式是什么?我想通过具有www.website.com/term/#,www.website.com/term/a,www.website.com/term/b,www.website.com/term/c,www的url进行迭代.website.com /学期/ d ... www.website.com/term/z格式如何在Python中遍历字母表?
45
A
回答
74
您可以使用string.ascii_lowercase
这是一个简单的小写字母便利串,
>>> from string import ascii_lowercase
>>> for c in ascii_lowercase:
... # append to your url
15
除了string.ascii_lowercase
你还应该看看内置的ord
和chr
。 ord('a')
会给你'a'
和chr(ord('a'))
的ascii值会给你回字符串'a'
。
使用这些可以通过字符代码进行递增和递减,并且可以轻松地来回转换。 ASCII table总是一个不错的书签。
相关问题
- 1. xsl遍历字母列表
- 2. 如何遍历Visual Basic中的字母表?
- 3. 如何遍历在Python
- 4. 如何遍历在Python
- 5. 遍历python中的字符串列表
- 6. Python遍历字典
- 7. 遍历Python列表只给每个字母
- 8. 遍历列表(Python)
- 9. 遍历在Python
- 10. 遍历在Python
- 11. 遍历在Python
- 12. 遍历在Python
- 13. 遍历在Python
- 14. 如何在Python中遍历Rtree 0.6.0
- 15. 如何遍历字符串数组Python
- 16. Python CSV如何遍历列表
- 17. 在Python中循环遍历数字
- 18. 在Python中遍历XML
- 19. 在Python中预先遍历
- 20. Python金字塔遍历
- 21. 如何在python中打印字母表?
- 22. 的Python 3:尝试基于功能遍历字母表中的行i
- 23. 如何在Lua中遍历表?
- 24. 的Python:遍历列表
- 25. Python循环遍历列表
- 26. 如何遍历字节数组列表...?
- 27. 如何遍历字典列表?
- 28. 如何遍历字典列表?
- 29. 如何在Python中以随机顺序遍历字典?
- 30. 如何遍历python中的optparse.OptionGroup值
有308,915,776(26^6)种方法可以用任何字母组合六个字母的长字符串 - 只是让您意识到如果您的工作进展超出了一个字母。 – Patashu