课程
/后端开发
/Python
/初识Python
print [x + y + z for x in '123456789' for y in '0123456789' for z in '123456789' if x == z] 结果一样,为何判我错
2015-09-25
源自:初识Python 10-4
正在回答
print [int(x + y + z) for x in '123456789'
for y in '0123456789'
for z in '0123456789'
if x == z]
转个类型,或者range(0, 9)生成数字。PS: range(x, y)左闭右开
print [x*100 + y*10 + z for x in range(1, 10)
for y in range(0, 10)
for z in range(0, 10)
要求输出是数字,不是字符串。弱语言方便也是蛋疼的地方
举报
学python入门视频教程,让你快速入门并能编写简单的Python程序