赞
踩
if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")
if len(a) > 10:
print(f"List is to long({len(a)} elements, expected <= 10)")
n = len(a)
if n > 10:
print(f"List is to long({n} elements, expected <= 10)")
discount = 0.0
if (mo := re.search(r'(\d+)% discount', advertisement)):
discount = float(mo.group(1)) / 100.0
discount = 0.0
mo = re.search(r'(\d+)% discount', advertisement)
if mo:
discount = float(mo.group(1)) / 100.0
# Loop over fixed length blocks
while (block := f.read(256)) != '':
process(block)
while 1:
block = f.read(256)
if block != '':
process(block)
else:
break
[clean_name.title() for name in names if (clean_name := normalize('NFC', name)) in allowed_names]
[o.title() for i in names if o:=f(i) in allowed_names]
# 在这里我把: clean_name normalize('NFC', name) 比做了一个方法
更简洁一点:
[y for x in names if (y := f(x))]
[f(x) for x in names if f(x)]
在Go里面,你需要用到 var 来进行赋值,如果你不想用var的话,就可以用 :=来进行赋值。
btw:学Go还真是有点蛋疼.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。