myStr = "abcdefghijgk"
'''
# n = len(myStr) throw out exception when compling
if n = len(myStr) > 10 :
print(f"{myStr} length: {n} is too long, expect less 10")
else:
print(f"{myStr} length: {n} is not too long, expect less 10")
'''
if (m := len(myStr)) > 10 :
print(f"{myStr} length: {m} is too long, expect less 10")
else:
print(f"{myStr} length: {m} is too long, expect less 10")
Python3 学习笔记 ~ 海象赋值表达式
最新推荐文章于 2024-07-25 22:24:14 发布