nauynah

nauynah

V2EX member #208413, joined on 2016-12-30 11:00:19 +08:00
nauynah's recent replies

之前 11dota 天梯单排的时候,碰到**队友,就会想要是还有 4 个自己肯定比他们强,本体玩辅助,其余 1234
Jan 22, 2018
Replied to a topic by holonunu Nintendo Switch Nintendo Switch 购买途径?
我前几天在香港买的,主机+奥德赛一共 2300rmb,在沙田站新城市广场苏宁
Sep 11, 2017
Replied to a topic by MrgHOST Python Python 相关问题
@acheapskate 是的,我把字符串长度看成 10 了
Sep 11, 2017
Replied to a topic by MrgHOST Python Python 相关问题
>>> [str[i: i+2] for i in range(0, 10, 2)]
Sep 4, 2017
Replied to a topic by hiboshi 问与答 Python 能实现这一的数据结构么
@hiboshi 三维也是一样的
```
tmp = dict()
tmp.setdefault(key1, {})
tmp[key1].setdefault(key2, {})
tmp[key1][key2][key3] = value
```
Sep 4, 2017
Replied to a topic by hiboshi 问与答 Python 能实现这一的数据结构么
可以。

```Python
aa = [
{'id': 1, 't_id': 100, 'txt': 'aaa'},
{'id': 1, 't_id': 110, 'txt': 'bbb'},
{'id': 1, 't_id': 120, 'txt': 'ccc'},
{'id': 2, 't_id': 130, 'txt': 'ddd'},
{'id': 2, 't_id': 140, 'txt': 'eee'},
{'id': 3, 't_id': 150, 'txt': 'fff'},
]

# 1、dict.setdefault 方法
tmp = dict()
for a in aa:
tmp.setdefault(a['id'], {})
tmp[a['id']][a['t_id']] = a['txt']

# 2、collections 模块 defaultdict
from collections import defaultdict
tmp = defaultdict(dict)
for a in aa:
tmp[a['id']][a['t_id']] = a['txt']
```
想知道暴风还要程序员吗,能祭天的那种
组成分母
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4089 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 04:13 · PVG 12:13 · LAX 21:13 · JFK 00:13
♥ Do have faith in what you're doing.