This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术 / 在看俄罗斯同事写的一段python 小程序
-walkthrough(roads);
2023-6-30
{1647}
(#15524179@0)
+1
-
f-string, 格式化字符串,还可以转义,具体放狗,这是PYTHON的基础知识
-eleclan(eleclan);
2023-6-30
(#15524192@0)
+3
-
这也知道?服了!
-walkthrough(roads);
2023-6-30
(#15524201@0)
+2
-
我当年写程序无师自通,从第一次装WIN95到学交大博士玩转SGI图形工作站(UNIX),到考NT的MCSE,到做C++项目(呼叫中心PBX板编程)到做游戏图形(DIRECTX OPENGL) 一共不到一年;我学东西很快
-eleclan(eleclan);
2023-6-30
(#15524216@0)
+2
-
你回复更快,7/24在线,机器人不过如此
-pili(小黑);
2023-6-30
(#15524294@0)
-
羡慕不?你做不上BOSS,可以考虑做个BOTS
-eleclan(eleclan);
2023-6-30
(#15524300@0)
+1
-
长发哥确定是个IT专业人士了。
-dw9857101(黑松鼠);
2023-6-30
(#15524390@0)
+3
-
他本来就是。全能
-programmer2017(zzz);
2023-6-30
(#15524393@0)
+2
-
长发哥真心不用再强调你无师自通了,因为大伙都知道你所有的事情都是无师自通的。
-kevin2011(Kevin);
2023-6-30
(#15524988@0)
-
我不挨踢,谁挨踢;要么我玩电脑的,要么我开卡车的,就像在左派看来,一个窗户都没打破的卡车司机是暴徒,我最早写程序时,那帮骂我的还在网吧玩游戏机器死机了只懂扯嗓子大叫“网管网管”,既不承认我是大老粗不识字的卡车司机,也不承认我是同行抢饭碗会说英文会写代码的IT人士,纠结不?
-eleclan(eleclan);
2023-6-30
{260}
(#15524406@0)
+2
-
这就能确定IT专业人士了?不懂任何编程的人请教ChatGPT ,几秒钟就有答案。ChatGPT 的回答:The "f" in f" is used to indicate that the string is an f-string, which stands for formatted string.
-blueskygg(Grass);
2023-6-30
(#15524458@0)
+1
-
能提出正确的问题就等于解决了一半的问题。
-walkthrough(roads);
2023-6-30
(#15524509@0)
+1
-
提SGI不用解释是UNIX的,画蛇添足了
-placid(cuba);
2023-6-30
(#15524579@0)
+1
-
当年我20岁,交大CS博士告诉我的
-eleclan(eleclan);
2023-6-30
(#15524590@0)
-
这段code就是典型的Linus Torvalds 说的缺乏Good Taste. 那么多的if, 完全碎嘴子,毫无美感可言。同样的逻辑可以用Pattern Match写成awe-inspiring。很多语言包括Python都支持。还有一个明显的错误,loc_sub_return 返回的时候可能没有值。程序会报错。
-hashicorp1(耶鲁妈妈);
2023-6-30
{69}
(#15524371@0)
+5
-
有返回值,是python 语法。
-programmer2017(zzz);
2023-6-30
(#15524386@0)
+1
-
是逻辑不是语法。loc_sub_return 从一堆if 里取值, 如果if都不满足,就拿不到值。return的时候会报错unboundlocalerror.
-hashicorp1(耶鲁妈妈);
2023-7-1
(#15524409@0)
+5
-
同感 - invert if statement + early return,再把另外几个 if 顺手 consolidate 一下,应该能减少 50% 缩进,50% code...
-xmlhttprequest(build5381);
2023-6-30
(#15524402@0)
+4
-
写法简洁运行会快吗?
-walkthrough(roads);
2023-6-30
(#15524529@0)
-
看具体情况吧。比如说 early return 不光能让 code 看起来易读,还通常能少运行很多步骤。主要是习惯问题,处处追求简洁优雅,才能做大。
-xmlhttprequest(build5381);
2023-6-30
(#15524592@0)
+1
-
耶鲁妈妈 威武!争取写出来的程序别人都看不懂。
-walkthrough(roads);
2023-6-30
(#15524514@0)
-
不才。不过看垃圾代码如同看钝刀杀人,难受啊。如果我这业余写码的人都看得出来,我绝对认同这些垃圾代码的缔造者转行去做labor, 每人领一张劳模好人贴 - 他们自己不嫌难受。
-hashicorp1(耶鲁妈妈);
2023-6-30
(#15524646@0)
+4
-
事实的情况是:在工作中90%代码不如这个。这个代码还算好了,容易看得懂,整断代码像乐谱一样整洁。虽然有很多的if else, 但不影响阅读。
-programmer2017(zzz);
2023-6-30
(#15524883@0)
+2
-
每个条件都有return 值,不要看楼主的text, 看截屏。这是典型的Python 命名风格啊。
-**🐓;
2023-6-30
(#15524607@0)
+1
-
这是典型的C披了Python的外衣。就命名来说,Ruby and Rust 也是这个风格。同意耶鲁妈妈,这不是一段高质量的代码 - 1 to 10低到高大约在3吧。
-mra(亲自当董事长);
2023-7-2
{121}
(#15527881@0)
+1
-
f string是python 大约3.7左右加入的吧。知道这个的应该是最近一直做IT的。
-moonhalf(石室矢);
2023-6-30
(#15525041@0)
+1