短路计算:
1.a(非空字符串)代表True,or的计算结果为a,返回值为python,然后输出:hello,python
2.b=''(空字符串)代表False, or的计算结果为b,返回值为world,然后输出:hello,world
1.a(非空字符串)代表True,or的计算结果为a,返回值为python,然后输出:hello,python
2.b=''(空字符串)代表False, or的计算结果为b,返回值为world,然后输出:hello,world
2016-03-25
L=[]
x = 1
if x <= 100:
L.append(x*x)
x = x+1
print sum(L)
else
print none
敢问大神,这段代码行不行
x = 1
if x <= 100:
L.append(x*x)
x = x+1
print sum(L)
else
print none
敢问大神,这段代码行不行
2016-03-25
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 1,2,3,4,5,6,7,8,9 ]:
if x < y:
print 10*x+y
for y in [ 1,2,3,4,5,6,7,8,9 ]:
if x < y:
print 10*x+y
2016-03-25
print [x*100 + y*10 + z for x in range(1,10) for y in range(0,10) for z in range(0,10) if x == z ]
2016-03-25
已采纳回答 / 清波
<...code...>这个逻辑很简单,题主仔细看的话,很快就能明白,我分步骤来讲下,这个函数的调用过程:调用square_of_sum([1, 2, 3, 4, 5])执行 <...code...> 在这一步,只是简单的做了一个列...
2016-03-25
已采纳回答 / 清波
如果缩进没有错误的话, 有这么几处错误:第二行,for y in [ 0,1,2,3,4,5,6,7,8,,9 ]: 8后面两个逗号第三行, if x<y 最后缺少冒号感觉 print x*10+y 的缩进少了一节
2016-03-25
python 3已经没有iteritems()这个函数了,应该用items(),教程能不能跟上时代啊,害得我找了半天错误!!!!!!!!!
2016-03-25