print("hello, python")
print("hello"+"python")
print("hello"+"python")
2019-05-30
最赞回答 / qq_慕神3467447
sum = 0x = 0while True: x = x + 1 if x > 100: break if x % 2 == 0: continue sum = sum + xprint sum
2019-05-30
print (45678 + int(0x12fd2))
print ("Learn Python in imooc")
print (100 < 99)
print (0xff == 255)
print ("Learn Python in imooc")
print (100 < 99)
print (0xff == 255)
2019-05-30
最新回答 / 慕数据3068636
搞混了吧?为什么不在return前判断?判断好了,根据判断拼接不同样式的html字符串就ok了,你是以前学过nodjs,vue的写法!!!!color=''if score<=60: color='color:red;'return '<tr><td>%s</td><td "style=\"%s\"">%s</td></tr>' % (name, color, score)
2019-05-30
已采纳回答 / 要努力的L
可以把key、:、d[key]看成字符、符号、数字三个元素,他们不是一个整体,要靠加号+或者逗号,连接起来。其中逗号万能,加号只能连接相同属性的元素。因此print有两种表达方式:1、print key,':' , d[key]2、print key+':'+str(d[key]) 这里的str是将括号里面的转化成字符元素
2019-05-30
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2019-05-30
其中 print ('<table border="1">')
border 为边框线条的宽度,添加了之后就会有表格边框
不及格成绩红色基于if判断语句
整个语句运行基于python 3,和python 2有点区别,python 3中使用items,已经没有iteritems这个方法了,请注意哦!
border 为边框线条的宽度,添加了之后就会有表格边框
不及格成绩红色基于if判断语句
整个语句运行基于python 3,和python 2有点区别,python 3中使用items,已经没有iteritems这个方法了,请注意哦!
2019-05-29
输出
print ('<table border="1">')
print ('<tr><th>Name</th><th>Score</th><tr>')
print ('\n'.join(tds))
print ('<table border="1">')
print ('<tr><th>Name</th><th>Score</th><tr>')
print ('\n'.join(tds))
2019-05-29
找到方法了
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.items()]
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.items()]
2019-05-29
print([a*100+b*10+c for a in range(1,10) for b in range(0,10) for c in range(1,10) if a==c])
2019-05-29
最新回答 / 慕粉4192555
s = set(['Adam', 'Lisa', 'Paul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']for n in L: if n in s: s.remove(n) else: s.add(n)print s
2019-05-29
好像我写了个最笨的
L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
2019-05-29
L = []
x = 1
while x <= 100:
L.append(x*x)
x += 1
print sum(L)
x = 1
while x <= 100:
L.append(x*x)
x += 1
print sum(L)
2019-05-29
sum = 0
x = 1
while True:
sum = sum + x
x = x + 2
if x > 100:
break
print sum
只循环奇数更方便
x = 1
while True:
sum = sum + x
x = x + 2
if x > 100:
break
print sum
只循环奇数更方便
2019-05-29