• <legend id='xOdaq'><style id='xOdaq'><dir id='xOdaq'><q id='xOdaq'></q></dir></style></legend>

    <small id='xOdaq'></small><noframes id='xOdaq'>

      <bdo id='xOdaq'></bdo><ul id='xOdaq'></ul>

        <i id='xOdaq'><tr id='xOdaq'><dt id='xOdaq'><q id='xOdaq'><span id='xOdaq'><b id='xOdaq'><form id='xOdaq'><ins id='xOdaq'></ins><ul id='xOdaq'></ul><sub id='xOdaq'></sub></form><legend id='xOdaq'></legend><bdo id='xOdaq'><pre id='xOdaq'><center id='xOdaq'></center></pre></bdo></b><th id='xOdaq'></th></span></q></dt></tr></i><div id='xOdaq'><tfoot id='xOdaq'></tfoot><dl id='xOdaq'><fieldset id='xOdaq'></fieldset></dl></div>
      1. <tfoot id='xOdaq'></tfoot>

      2. python中的字符范围

        range over character in python(python中的字符范围)
      3. <small id='9zyru'></small><noframes id='9zyru'>

          <tbody id='9zyru'></tbody>
            <legend id='9zyru'><style id='9zyru'><dir id='9zyru'><q id='9zyru'></q></dir></style></legend>
              <bdo id='9zyru'></bdo><ul id='9zyru'></ul>

                  <tfoot id='9zyru'></tfoot>
                1. <i id='9zyru'><tr id='9zyru'><dt id='9zyru'><q id='9zyru'><span id='9zyru'><b id='9zyru'><form id='9zyru'><ins id='9zyru'></ins><ul id='9zyru'></ul><sub id='9zyru'></sub></form><legend id='9zyru'></legend><bdo id='9zyru'><pre id='9zyru'><center id='9zyru'></center></pre></bdo></b><th id='9zyru'></th></span></q></dt></tr></i><div id='9zyru'><tfoot id='9zyru'></tfoot><dl id='9zyru'><fieldset id='9zyru'></fieldset></dl></div>

                  本文介绍了python中的字符范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法跨越字符?像这样的.

                  Is there an way to range over characters? something like this.

                  for c in xrange( 'a', 'z' ):
                      print c
                  

                  希望大家帮忙

                  推荐答案

                  这是自定义生成器的绝佳用途:

                  This is a great use for a custom generator:

                  Python 2:

                  def char_range(c1, c2):
                      """Generates the characters from `c1` to `c2`, inclusive."""
                      for c in xrange(ord(c1), ord(c2)+1):
                          yield chr(c)
                  

                  然后:

                  for c in char_range('a', 'z'):
                      print c
                  

                  <小时>

                  Python 3:

                  def char_range(c1, c2):
                      """Generates the characters from `c1` to `c2`, inclusive."""
                      for c in range(ord(c1), ord(c2)+1):
                          yield chr(c)
                  

                  然后:

                  for c in char_range('a', 'z'):
                      print(c)
                  

                  这篇关于python中的字符范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                2. <tfoot id='Dprkv'></tfoot>
                    <bdo id='Dprkv'></bdo><ul id='Dprkv'></ul>
                      <tbody id='Dprkv'></tbody>

                          <small id='Dprkv'></small><noframes id='Dprkv'>

                        • <legend id='Dprkv'><style id='Dprkv'><dir id='Dprkv'><q id='Dprkv'></q></dir></style></legend>

                        • <i id='Dprkv'><tr id='Dprkv'><dt id='Dprkv'><q id='Dprkv'><span id='Dprkv'><b id='Dprkv'><form id='Dprkv'><ins id='Dprkv'></ins><ul id='Dprkv'></ul><sub id='Dprkv'></sub></form><legend id='Dprkv'></legend><bdo id='Dprkv'><pre id='Dprkv'><center id='Dprkv'></center></pre></bdo></b><th id='Dprkv'></th></span></q></dt></tr></i><div id='Dprkv'><tfoot id='Dprkv'></tfoot><dl id='Dprkv'><fieldset id='Dprkv'></fieldset></dl></div>