码迷,mamicode.com
首页 > 编程语言 > 详细

列表生成式和三元表达式(python3入门)

时间:2018-11-27 23:20:17      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:判断   三元   pre   span   nbsp   range   python3   class   col   

 1 #一行代码编写一个列表
 2 li = [%s_qqq%i for i in range(1,11) if i > 4]
 3 print(li)
 4 
 5 
 6 
 7 x =input(>>)
 8 y = input(>>)
 9 #一行代码做判断并得出所要的结果
10 res = x if x > y else y
11 print(res)

 

列表生成式和三元表达式(python3入门)

标签:判断   三元   pre   span   nbsp   range   python3   class   col   

原文地址:https://www.cnblogs.com/lich1x/p/10029694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!