V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hellogitooxx
V2EX  ›  Python

求教,我有一组字典数据,想得到: data 里的数每三个一组,把后面的 f,z,l,t 列按竖输出。

  •  
  •   hellogitooxx · 2021-04-26 13:17:31 +08:00 · 1249 次点击
    这是一个创建于 1089 天前的主题,其中的信息可能已经有所发展或是发生改变。

    datas={'name': 'xxxx ', 'leixing': '2', 'data': 'BBPPPPBPPPBPBBBBPBPB', 'f': '**√', 'z': '√√*√√√', 'l': '√√√x√x', 't': '√x√√x√'}

    效果如下: https://z3.ax1x.com/2021/04/26/gS1jr6.jpg

    6 条回复    2021-04-27 00:37:19 +08:00
    imn1
        1
    imn1  
       2021-04-26 13:25:21 +08:00   ❤️ 2
    图片和例子不同,逻辑对应不了
    princelai
        2
    princelai  
       2021-04-26 13:39:25 +08:00   ❤️ 1
    描述的不清楚没能理解
    no1xsyzy
        3
    no1xsyzy  
       2021-04-26 14:10:58 +08:00   ❤️ 4
    (等你描述清楚了,你也就写出来了。
    chionetw5
        4
    chionetw5  
       2021-04-26 14:28:46 +08:00   ❤️ 1
    datas={'name': 'xxxx ', 'leixing': '2', 'data': 'BBPPPPBPPPBPBBBBPBPB', 'f': '**√√', 'z': '√√*√√√', 'l': '√√√x√x', 't': '√x√√x√'}
    group_data = [datas['data'][_:_+3] for _ in range(0,len(datas['data']), 3)]
    for index, data in enumerate(group_data):
    print(datas['name'], datas['leixing'], data, datas['f'][index:index+1], datas['z'][index:index+1], datas['l'][index:index+1], datas['t'][index:index+1])
    hellogitooxx
        5
    hellogitooxx  
    OP
       2021-04-26 15:30:32 +08:00
    @chionetw5 感谢你,就是这个意思
    zzxgz
        6
    zzxgz  
       2021-04-27 00:37:19 +08:00
    leixing 还行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4583 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:04 · PVG 18:04 · LAX 03:04 · JFK 06:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.