• <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中的字符范围

        时间:2023-11-08
      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中的字符范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:`xrange(2**100)` -&gt;溢出错误:long int 太大而无法转换为 int 下一篇:多个范围的并集

                  相关文章

                2. <tfoot id='Dprkv'></tfoot>
                    <bdo id='Dprkv'></bdo><ul id='Dprkv'></ul>

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

                    1. <legend id='Dprkv'><style id='Dprkv'><dir id='Dprkv'><q id='Dprkv'></q></dir></style></legend>

                    2. <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>