zyb201314's recent timeline updates
zyb201314

zyb201314

V2EX member #527254, joined on 2021-01-07 10:18:39 +08:00
求助一个正则表达式.
JavaScript  •  zyb201314  •  Apr 17, 2024  •  Lastly replied by zyb201314
13
[新手] 不懂就问.
JavaScript  •  zyb201314  •  Apr 20, 2021  •  Lastly replied by libook
13
open()读取文件问题(假设思考题).
Python  •  zyb201314  •  Jan 20, 2021  •  Lastly replied by AoEiuV020
11
zyb201314's recent replies
Apr 17, 2024
Replied to a topic by zyb201314 JavaScript 求助一个正则表达式.
这种问题解决的方式或许有很多, 一为的学习, 2 为了解决问题, 直觉用正则解解决这种问题应该最简洁, 也是它的能力范围,但我想到的处理方式太过复杂,不是我想要的.
感谢 @ramirezyolis808 的/[^=,]*6[^,]*/g,感谢各位大佬, 此贴就此终结.
Apr 20, 2021
Replied to a topic by zyb201314 JavaScript [新手] 不懂就问.
谢谢各位,让我明白了这是个坑.
糟粕+1
let user = {};
user.name = "MR.Zhang";

user.func=function(x){
let y = x => x +"! " + this.name;
return y(x);
}

// 等效于:
/*
user.func=function(x){
return x +"! " + this.name
}
*/

console.log(user.func("你好"));
Apr 20, 2021
Replied to a topic by zyb201314 JavaScript [新手] 不懂就问.
谢谢各位. 是否可理解为箭头函数的不支持 this ?
Mar 26, 2021
Replied to a topic by 2bin Python 请教 Python 中 xpath 如何实现这种需求
#这样?
html = etree.HTML(html_str)
lst=[]
for a in html.xpath('//span//a'):
content = a.xpath('.//text()')
l=''.join("".join(content).split()).replace('"',"")
lst.append(l)
print(lst)
Mar 24, 2021
Replied to a topic by badacook Python pandas.DataFrame 的列筛选
print(result[result.code.str.contains("sz")&result.code_name.str.contains("B")])
Mar 23, 2021
Replied to a topic by going Python Python 高性能小算法
#这咋样?
import heapq
s=[9,2,3,6,10,5,7,1,8]
print(sum(heapq.nsmallest(3,s)))
print(sum(heapq.nlargest(3,s)))
辛苦、支持! 加星收藏
这里(?:exp)没有必要吧?
还有例子字符串中除了 float 中有'点', 没有其它单独的'点'.那么直接获取数字和点就 ok 了.如:
s="0.7-1 万 /元;"
print(re.findall("[\d\.]+" , s))
Mar 16, 2021
Replied to a topic by plko345 Python 请教一个 dict 中取相同 value 的方法
#竟然没人用一楼方案?
data = [
{
"labels": {
"k_1": "v_1",
"k_2": "v_2",
"k_3": "v_3_1"
}
},
{
"labels": {
"k_1": "v_1",
"k_2": "v_2",
"k_3": "v_3_2"
}
}
]
################################
label_name = next((next((j for j in i)) for i in data))
labels = data[0][label_name]
#获取第一个 labels 的字典.
targets = {}
################################
for d in data:
for j in d:
labels = dict(labels.items() & d[j].items())
targets = dict(targets.items() ^ d[j].items())
################################
data=[{str(label_name): labels},{'targets': targets}]
print(data)
Mar 7, 2021
Replied to a topic by lxl1531 Python Python 的字符串拼接函数 join()是怎么实现的
join()会不会先计算整个列表需要的空间,类似一次性申请足够空间合并所有字符串, 是否有字符串缓冲机制实现类似列表 append 就地增加字符串?
而用 for 需要不断地申请字符串扩容和迁移,随着合并的字符串越多,迁移越来越慢.
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4301 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
♥ Do have faith in what you're doing.