标签:pen app inpu max exp 生成器 expr return strip
# 三元表达式
# def my_max(x,y):
# if x >= y:
# return x
# else:
# return y
#
# res=my_max(1,2)
# print(res) # 2
# x=10
# y=20
# res=x if x >= y else y
#
# print(res) # 20
# name=input(‘>>:name‘).strip()
# res=‘Yes‘ if name == ‘OBOS‘ else ‘No‘
#
# print(res)
# 列表推导式
# l=[]
# for i in range(1,11):
# res=‘apple‘+str(i)
# l.append(res)
#
# print(l) # [‘apple1‘, ‘apple2‘, ‘apple3‘, ‘apple4‘, ‘apple5‘, ‘apple6‘, ‘apple7‘, ‘apple8‘, ‘apple9‘, ‘apple10‘]
# l=[‘apple‘+str(i)for i in range(1,11)]
#
# print(l) # [‘apple1‘, ‘apple2‘, ‘apple3‘, ‘apple4‘, ‘apple5‘, ‘apple6‘, ‘apple7‘, ‘apple8‘, ‘apple9‘, ‘apple10‘]
# l=[‘apple‘+str(i)for i in range(1,11) if i >= 6]
#
# print(l) # [‘apple6‘, ‘apple7‘, ‘apple8‘, ‘apple9‘, ‘apple10‘]
# 生成器表达式
# l=(‘apple‘+str(i)for i in range(0,1000000000000000000000000000000000000000000))
# print(l) # <generator object <genexpr> at 0x000001DB312DEAC8>
#
# l.__iter__()
# l.__next__()
#
# print(next(l))
# print(next(l))
# print(next(l))
‘‘‘
apple1
apple2
apple3
‘‘‘
标签:pen app inpu max exp 生成器 expr return strip
原文地址:https://www.cnblogs.com/0B0S/p/11997653.html