精华内容
下载资源
问答
  • 我有一个名为值的列表,其中包含一系列数字:values = [0, 1, 2, 3, 4, 5, ...... , 559]我想创建一个新列表,其中包含从0到数字的元素列表.喜欢 :new_values = [[0, 1, 2, ... , 351], [0, 1, 2, ... ,...

    我有一个名为值的列表,其中包含一系列数字:

    values = [0, 1, 2, 3, 4, 5, ... , 351, 0, 1, 2, 3, 4, 5, 6, ... , 750, 0, 1, 2, 3, 4, 5, ... , 559]

    我想创建一个新列表,其中包含从0到数字的元素列表.

    喜欢 :

    new_values = [[0, 1, 2, ... , 351], [0, 1, 2, ... , 750], [0, 1, 2, ... , 559]]

    我做的代码是这样的:

    start = 0

    new_values = []

    for i,val in enumerate(values):

    if(val == 0):

    new_values.append(values[start:i])

    start = i

    但是,它将返回以下内容:

    new_values = [[], [0, 1, 2, ... , 750], [0, 1, 2, ... , 559]]

    如何修复我的代码?这将确实有很大的帮助.

    解决方法:

    您可以基于0(很虚假)的存在,使用itertools.groupby对元素进行分组,并提取0之间的子列表,同时在缺失的0后面附加列表理解:

    [[0]+list(g) for k, g in groupby(values, bool) if k]

    例:

    >>> from itertools import groupby

    >>> values = [0, 1, 2, 3, 4, 5 , 351, 0, 1, 2, 3, 4, 5, 6, 750, 0, 1, 2, 3, 4, 559]

    >>> [[0]+list(g) for k, g in groupby(values, bool) if k]

    [[0, 1, 2, 3, 4, 5, 351], [0, 1, 2, 3, 4, 5, 6, 750], [0, 1, 2, 3, 4, 559]]

    标签:python,list

    展开全文
  • REPORTz.TYPE-POOLS:vrm.DATA:it_valTYPEvrm_values,w_lineLIKELINEOFit_val.PARAMETERSp_bukrsLIKEt001-bukrsASLISTBOXVISIBLELENGTH25OBLIGATORY.INITIALIZATION.SELE...

    REPORT z.
     TYPE-POOLS: vrm.
     DATA: it_val TYPE vrm_values,
           w_line LIKE LINE OF it_val.
     PARAMETERS p_bukrs LIKE t001-bukrs AS LISTBOX
                VISIBLE LENGTH 25 OBLIGATORY.

     INITIALIZATION.
       SELECT bukrs butxt FROM t001 INTO (w_line-key, w_line-text).
         APPEND w_line TO it_val.
         CHECK p_bukrs IS INITIAL.
         p_bukrs = w_line-key.
       ENDSELECT.

     AT SELECTION-SCREEN OUTPUT.
       CALL FUNCTION 'VRM_SET_VALUES'
         EXPORTING
           id     = 'P_BUKRS'
           values = it_val.

     END-OF-SELECTION.
       WRITE: / 'Company Code:', p_bukrs.

      REPORT yaowei_test_list .
    TABLES:t001.
    DATA: ok_code LIKE sy-ucomm.
    *下拉列表相关定义
    TYPE-POOLS vrm. "下拉列表使用的类型定义
    DATA: sc_list TYPE vrm_id. "使用列表的字段名
    DATA:it_list TYPE vrm_values. "使用列表的清单内容
    DATA: wa_list LIKE LINE OF it_list.
    "创建列表清单使用的工作区
    "不能自己定义内表,一定要用VRM_VALUES.其他有2个字段:KEY AND TEXT
    DATA p_bukrs LIKE t001-bukrs.

    START-OF-SELECTION.
      CALL SCREEN 100.
      "或PARAMETERS: SC_LIST(20) AS LISTBOX VISIBLE LENGTH 10.

    *&---------------------------------------------------------------------*
    *& Module STATUS_0100 OUTPUT
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    MODULE status_0100 OUTPUT.
      SET PF-STATUS '100'.
    * SET TITLEBAR 'xxx'.


      REFRESH it_list. "勿忘
      SELECT bukrs butxt FROM t001 INTO (wa_list-key, wa_list-text).
        APPEND wa_list TO it_list.
        CHECK p_bukrs IS INITIAL.
        p_bukrs = wa_list-key.
      ENDSELECT.

      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = 'P_BUKRS'
          values = it_list."屏幕中的下拉菜单的NAME,下拉菜单选择LISTBOX
    *WITH KEY 若选LISTBOX的话带不出KEY值
      REFRESH it_list.
    ENDMODULE. " STATUS_0100 OUTPUT
    *&---------------------------------------------------------------------*
    *& Module USER_COMMAND_0100 INPUT
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
      CASE: ok_code.
        WHEN: 'BACK'.
          LEAVE TO SCREEN 0.
    *WHEN: 'LIST_SEL'.
    *MESSAGE 'LIST_SEL' TYPE 'I'.
      ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT

    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/CompassButton/archive/2006/08/19/1097624.aspx

    转载于:https://www.cnblogs.com/clsoho/archive/2010/01/25/1655867.html

    展开全文
  • 创建列表

    2017-07-17 19:57:00
    create table yyy(s# number(2) primary key, --创建 行name varchar2(6), age NUMBER(2),sex varchar2(2),post varchar2(6));insert into yyy values (01,'赵倩','26','女','店长'); --创建 列insert into yyy v...

    create table yyy
    (s# number(2) primary key,     --创建 行
    name varchar2(6),       
    age NUMBER(2),
    sex varchar2(2),
    post varchar2(6)
    );

    insert into yyy values (01,'赵倩','26','女','店长');    --创建 列
    insert into yyy values (02,'孙俪','23','女','店员');
    insert into yyy values (03,'李亮','21','男','店员');

    转载于:https://www.cnblogs.com/hyx0920/p/7197256.html

    展开全文
  • I have a list named values containing a series of numbers:values = [0, 1, 2, 3, 4, 5, ... , 351, 0, 1, 2, 3, 4, 5, 6, ... , 750, 0, 1, 2, 3, 4, 5, ... , 559]I want to create a new list that contains a...

    I have a list named values containing a series of numbers:

    values = [0, 1, 2, 3, 4, 5, ... , 351, 0, 1, 2, 3, 4, 5, 6, ... , 750, 0, 1, 2, 3, 4, 5, ... , 559]

    I want to create a new list that contains a list of elements from 0 up to a number.

    Like :

    new_values = [[0, 1, 2, ... , 351], [0, 1, 2, ... , 750], [0, 1, 2, ... , 559]]

    The code that I did was this:

    start = 0

    new_values = []

    for i,val in enumerate(values):

    if(val == 0):

    new_values.append(values[start:i])

    start = i

    However, what it returns this:

    new_values = [[], [0, 1, 2, ... , 750], [0, 1, 2, ... , 559]]

    How can I fix my code? It will really be a great help.

    解决方案

    You can group your elements with itertools.groupby based on the presence of 0 (which is falsy) and extract the sublists between 0 while appending the missing 0 with a list comprehension:

    [[0]+list(g) for k, g in groupby(values, bool) if k]

    Example:

    >>> from itertools import groupby

    >>> values = [0, 1, 2, 3, 4, 5 , 351, 0, 1, 2, 3, 4, 5, 6, 750, 0, 1, 2, 3, 4, 559]

    >>> [[0]+list(g) for k, g in groupby(values, bool) if k]

    [[0, 1, 2, 3, 4, 5, 351], [0, 1, 2, 3, 4, 5, 6, 750], [0, 1, 2, 3, 4, 559]]

    展开全文
  • Android创建列表并为列表添加数据

    千次阅读 2019-02-26 22:08:00
    在Android开发中经常会用到ListView,也就是列表,而列表的内容需要...在布局文件中,创建一个ListView,其内容在values文件夹下的arrays.xml文件中 <ListView android:layout_width="match_parent" andr...
  • Android Studio 创建对应国家语言 values

    千次阅读 2018-08-21 00:41:52
    2.在弹出框里下方左侧列表点击 Locale,然后再点击中间的 ...3.在Language列表和Specific Region Only列表下选择相对应的选项, 比如你要创建中文适配的values文件夹,就在Language选择zh:Chinese,在Specific Re...
  • Python ttk创建下拉列表

    2020-04-06 12:09:51
    ttk创建下拉列表 import tkinter from tkinter import ttk def create_win(): win = tkinter.Tk() combobox = ttk.Combobox(win) #创建下拉框 combobox["values"]=("大","中","小") #设置各选项的值 ...
  • VALUES提供了一种生成“常量表”的方法,它可以被使用在一个查询中而不需要实际在磁盘上创建一个表。语法是: VALUES ( expression [, ...] ) [, ...] 每一个被圆括号包围的表达式列表生成表中的一行。列表都必须...
  • Tensorflow中有三种创建常数数据的方式,分别是Constants, Sequences, 和 Random Values。 1.Constants:产生常数Tensor tf.zeros(shape, dtype=tf.float32, name=None) shape:int列表或者一个1维的Tensor ...
  • 我试图从一组列表创建字符串.这是我目前拥有的:#contains categoriesnumind = [('Length',),('Fungus',)]#contains values that pertain to the categoriesrecords = [('Length','Long'),('Length','Med'),'Yes')...
  • 7.7. VALUES Lists

    2021-01-02 13:08:59
    7.7.VALUES列表 VALUES provides a way to generate a “constant table” that can be used in a query without having toactually create and populate a table on-disk. The syntax is VALUES提供了一种生成可...
  • <pre><code>$my_values = array(); while ($data=mysqli_fetch_assoc($result)) { foreach ($data as $key => $value) { $my_values[] = $value; } } print_r($my_values); </code></pre> <p>and this is the...
  • 创建动态下拉列表

    2011-01-28 05:00:57
    //Get all the values out of the district array out of pdo.vhd $districtsSelected = removeUnselected(".$_SESSION['provincesresults'][$key][0]."); } ?>\"; } </code></pre> <p> <p>So I need ...
  • 如何创建PHP下拉列表

    2014-03-13 02:58:38
    <p>I am trying to build a php contact form with a dropdown list of values, say "A", "B" and "C", that fits the code structure below. <p>As well, I would like to call this form from a link on another ...
  • I am trying to make generic config, and thus config parser. There are two config files say A and... I want to parse sections and make global values from them according to hardcoded list.Here is an exa...
  • 检查下面的代码: String jsonString = writer.toString(); JSONObject jsonObj = new JSONObject(jsonString); defaultCurrencyValue = jsonObj.getString...如何在数组列表中保存 key和 它的 values
  • <p>What I need is to add the values to a text field at the bottom of the form (say, name="allpoints") that concatenates the field values from this list (the text field labelled "savedpoints", with the...
  • 我需要从列表列表创建二叉树.我的问题是一些节点重叠(在一个意义上,一个节点的左边是另一个节点的右边),我想将它们分开.我复制了重叠的节点并创建了一个列表,但我遗漏了一些东西.我用来做的代码:self.root = root...
  • One list contains values and one is empty. I want to take out two values from the list with data and place it into the empty list using a for loop. I know how to get one value. However, I am not sure ...
  • 创建list(列表)分区!

    千次阅读 2011-09-28 17:38:04
    --创建list分区表: SQL> create table t_partition_list (id number,name varchar2(50)) 2 partition by list(id)( 3 partition t_list_p1 values
  • 小编典典lst_col = 'samples'r = pd.DataFrame({col:np.repeat(df[col].values, df[lst_col].str.len())for col in df.columns.drop(lst_col)}).assign(**{lst_col:np.concatenate(df[lst_col].values)})[df.columns...
  • //leave out the data key to pass all form values through ))); //empty since it will be filled by the other dropdown echo CHtml::dropDownList('city_id','', array()); ?> </code></pre> </div>
  • <p>i have a list like this: <pre><code>array( ...<p>i cannot use things like nested set or things like that becoas i can add left and right values in my database. any ideas? </div>
  • <p>I have a directory of files who's main purpose is to store php variables for inclusion into other files in the site. Each file contains the same set of variables, but with different values....
  • I have a python dictionaryd = {1: 6, 2: 1, 3: 1, 4: 9, 5: 9, 6: 1}Since the values in the above dictionary are not unique. I want to group the all the keys of unique values as a list and create a new ...
  • PRESTO的VALUES使用

    2020-05-08 16:04:11
    概要 VALUES row [, ...] 其中, `row`是一个表达式,或者是如下形式的表达式列表: ( column_expression [, ...] ) 描述 ...VALUES默认创建一张匿名表,并且没有列名。表名和列名可以通过AS...
  • 让我们有一个值列表和一个任意整数.values = ['5', '3', '.', '.', '7', '.', '.', '.', '.', '6', '.', '.', '1', '9', '5', '.', '.', '.', '.', '9', '8', '.', '.', '.', '.', '6', '.', '8', '.', '.', '.', '6...
  • <p>I am working on a project and would like to give the user per-determined values when updating a record. <p>Here is my code so far. <pre><code> <?php // if there are any errors, display them ...
  • ProjectInfo.objects.all().values('pro_name').order_by('create_time') print(project) if request.is_ajax(): testcase_lists = json.loads(request.body.decode('utf-8')) msg...
  • numpy插入一列: aa = np.insert(bb,682,values = cc,axis=1) ...创建字典(键h不可以为数组): dic = dict(zip(key,value)) dic = dict(zip(键,值)) 遍历字典: for key, value in dic.items(): if...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 656
精华内容 262
关键字:

values创建列表