作者ruthertw (督人无数就是我)
看板Python
标题[问题] 这两句没注释的程式码,恳请翻译教学.
时间Thu Jan 12 18:02:19 2023
Github上一堆不写注释的,
搞不懂以下两句:
if o_filename not in map(lambda img: img['filename'], imgs):
...
...
...
else:
img = [ele for ele in imgs if ele['filename'] == o_filename][0]
这两句python看不懂,
卡一天了.
也想附带请教,
为何产生的档案名称长度会被截断?
例如,
原档案名称:
abcdefghijklmnopqrstuvwxyz.png
最後产生的档案名称的长度会被截断,
变成例如,
abcdefghijkl.png
这两句没注释的程式码,
恳请翻译教学.
先谢谢大大们了~
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 130.34.173.112 (日本)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1673517741.A.4D5.html
1F:推 a129924: 第一段是o_file假如没有在imgs内的img元素的filename里面 01/12 20:26
2F:推 a129924: 第二段是 img = imgs里面的ele 并且ele["filename"] == o 01/12 20:29
3F:→ a129924: file["filename"] 01/12 20:29
4F:推 eight0: if any(o_filename == i['filename'] for i in imgs): 01/12 21:04
5F:→ eight0: 第一段写成上面那样可能比较好懂 01/12 21:05
6F:→ eight0: 啊不过我写反了 01/12 21:06
7F:→ lycantrope: 就简单到不用写注解... 01/12 22:25
8F:→ ddavid: 说人家不写注解你看不懂,你发问也没注解你哪边不懂XD 01/13 17:13
9F:→ ddavid: 谁会知道你是 lambda 不懂、map 不懂、list comprehension 01/13 17:13
10F:→ ddavid: 不懂还是更奇怪的哪边不懂XD 01/13 17:14
11F:→ ddavid: 至於档名长度的问题就真的太通灵了,建议至少讲一下是哪个 01/13 17:40
12F:→ ddavid: repo 01/13 17:40
13F:嘘 aalexx: 嘘第一句 没注释看不懂是你的问题 程式码都在那了 01/14 02:25
14F:嘘 wuyiulin: 人家都开源了,还要帮你写注解?又不是公司对接同事 01/14 11:13
15F:嘘 newsph: 第一句感觉像是欠你的?吃免钱还嫌 01/16 11:10
16F:→ TakiDog: 但这段看起来有臭味 01/17 02:56
17F:推 jasonfghx: 真的难 01/17 16:54
18F:嘘 LincolnBoy: 嗯 01/21 14:04
19F:→ leolarrel: 跟我初七坐客运到鹿港遇到的台湾鲷一样."鹿港到了? 阿 01/30 10:01
20F:→ leolarrel: 司机你是不会讲一下鹿港到了喔+(酸话连发)" 01/30 10:02