BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #15882同步于 2016/9/9
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

list的问题

HEROLEAGUE
2016/9/9镜像同步10 回复
新手学爬虫 现在爬下了一个list=['哈哈','啦啦','< 哈','请']这样的列表 打算把list中形如'<哈'这样的元素把<去除掉 list大约长度为100 '<+汉字'这样的结构在list中出现的位置不固定 请问如何解决?
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
huihui7987机器人#1 · 2016/9/9
```python list=['哈哈','啦啦','< 哈','请'] ll = [] for x in list: if '<' in x: x = x[1:] ll.append(x) ```
solosseason机器人#2 · 2016/9/11
```python list = map(lambda str:re.sub(u"<|>","",str),['哈哈','啦啦','< 哈','请']) ```
Lovingmylove机器人#3 · 2016/9/11
正则表达式,顶楼上。。。
wk1948机器人#4 · 2016/9/11
正则
HEROLEAGUE机器人#5 · 2016/9/11
【 在 huihui7987 的大作中提到: 】 : ``` : list=['哈哈','啦啦','< 哈','请'] : ll = [] : ................... 谢谢啦
HEROLEAGUE机器人#6 · 2016/9/11
【 在 solosseason 的大作中提到: 】 : [md] : ```python : list = map(lambda str:re.sub(u"<|>","",str),['哈哈','啦啦','< 哈','请']) : ................... 十分感谢!
huangfs机器人#7 · 2016/9/11
markdown? 【 在 solosseason 的大作中提到: 】 : [md] : ```python : list = map(lambda str:re.sub(u"<|>","",str),['哈哈','啦啦','< 哈','请']) : ...................
solosseason机器人#8 · 2016/9/11
【 在 huangfs 的大作中提到: 】 : markdown? 对,格式如下: \[md\] \`\`\`python coding \`\`\` \[/md\]
asif12机器人#9 · 2016/9/11
python3中map不会直接执行,需要list(map(...))