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

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

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

      1. 检查十六进制值列表是否是连续的

        Check whether a list of hexadecimal values is sequential or not(检查十六进制值列表是否是连续的)

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

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

                    <tbody id='GxtN0'></tbody>
                  <tfoot id='GxtN0'></tfoot>
                  本文介绍了检查十六进制值列表是否是连续的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  想要一个函数/语句,检查mylist的所有值是否是连续的,即hexadecimal列表.例如:

                  Want a function / statement, to check whether all the values of mylist are sequential or not, which is hexadecimal list. For example:

                  def checkmylist(mylist):
                      #code returns True or False
                  
                  
                  mylist1 = ['03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c','0d', '0e', '0f']
                  mylist2 = ['03', '05', '06', '07', '08', '09', '0a', '0b', '0c','0d', '0e', '0f']
                  
                  checkmylist(mylist1)
                  #expected to returns pass
                  checkmylist(mylist2)
                  #expected to returns fail
                  

                  推荐答案

                  def checkmylist(mylist):
                      it = (int(x, 16) for x in mylist)
                      first = next(it)
                      return all(a == b for a, b in enumerate(it, first + 1))
                  

                  在第一条语句中,我们将十六进制数转换为整数生成器.使用 next(it) 我们获取生成器的第一个元素.然后我们枚举从 first + 1 开始编号的其余元素.如果每个元素的编号与元素本身相同,则我们得出结论,我们有一个顺序列表.

                  With the first statement we convert the hex numbers to a generator of integers. With next(it) we take the first element of the generator. Then we enumerate the rest of the elements starting the numbering from first + 1. We conclude that we have a sequential list if the numbering of each element is the same as the element itself.

                  这篇关于检查十六进制值列表是否是连续的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Running .jl file from R or Python(从 R 或 Python 运行 .jl 文件)
                  Running Julia .jl file in python(在 python 中运行 Julia .jl 文件)
                  Using PIP in a Azure WebApp(在 Azure WebApp 中使用 PIP)
                  How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                  Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                  Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
                  <i id='IwRph'><tr id='IwRph'><dt id='IwRph'><q id='IwRph'><span id='IwRph'><b id='IwRph'><form id='IwRph'><ins id='IwRph'></ins><ul id='IwRph'></ul><sub id='IwRph'></sub></form><legend id='IwRph'></legend><bdo id='IwRph'><pre id='IwRph'><center id='IwRph'></center></pre></bdo></b><th id='IwRph'></th></span></q></dt></tr></i><div id='IwRph'><tfoot id='IwRph'></tfoot><dl id='IwRph'><fieldset id='IwRph'></fieldset></dl></div>

                      <legend id='IwRph'><style id='IwRph'><dir id='IwRph'><q id='IwRph'></q></dir></style></legend>
                    • <small id='IwRph'></small><noframes id='IwRph'>

                        <bdo id='IwRph'></bdo><ul id='IwRph'></ul>
                          <tbody id='IwRph'></tbody>
                        <tfoot id='IwRph'></tfoot>