三层两层的都可以实现啊
>>> print [m*100+n*10+k for m in range(1,10) for n in range(10) for k in range(10) if (m == k)]
>>> print [m*100+n*10+m for m in range(1,10) for n in range(10)]
>>> print [m*100+n*10+k for m in range(1,10) for n in range(10) for k in range(10) if (m == k)]
>>> print [m*100+n*10+m for m in range(1,10) for n in range(10)]
2018-04-30
其实例子很简单,比如这样,或许更容易看懂一些
>>> d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
>>> tds = ['name2:%s,Score2:%s' % (name, score) for name, score
in d.iteritems()];
>>> print "\n ".join(tds)
name2:Lisa,Score2:85
name2:Adam,Score2:95
name2:Bart,Score2:59
>>> d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
>>> tds = ['name2:%s,Score2:%s' % (name, score) for name, score
in d.iteritems()];
>>> print "\n ".join(tds)
name2:Lisa,Score2:85
name2:Adam,Score2:95
name2:Bart,Score2:59
2018-04-30
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L.pop(2)
L.pop(2)
print L
2018-04-30
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0]+':',x[1]
for x in s:
print x[0]+':',x[1]
2018-04-30
for x in [ 1,2,3,4,5,6,7,8 ]:
for y in [2,3,4,5,6,7,8,9 ]:
if x < y :
print x*10+y
for y in [2,3,4,5,6,7,8,9 ]:
if x < y :
print x*10+y
2018-04-30
不变红色好像是这个预览的关系
print r'''<table border="1">
<tr><th>Name</th><th>Score</th><tr>
<tr><td style=color:red>Lisa</td><td>85</td></tr>
<tr><td>Adam</td><td>95</td></tr>
<tr><td>Bart</td><td>59</td></tr>
</table>'''
print r'''<table border="1">
<tr><th>Name</th><th>Score</th><tr>
<tr><td style=color:red>Lisa</td><td>85</td></tr>
<tr><td>Adam</td><td>95</td></tr>
<tr><td>Bart</td><td>59</td></tr>
</table>'''
2018-04-30
# -*- coding: utf-8 -*-
d = {95:'Adam',85:'Lisa',59:'Bart'
}
print d.get(95)
d = {95:'Adam',85:'Lisa',59:'Bart'
}
print d.get(95)
2018-04-30