我的代码为什莫在python3.5环境中是错误的

d={'yindi':99,'huyu':80,'miaonin':88,'lihan':40}

def libiao(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=[libiao(name,score) for name,score in d.iteritems()]

print'<table border="1">'

print'<tr><th>name</th><th>score</th><tr>'

print'\n'.join(tds)

print'</table>'


   错误原因:exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/python/biaoge.py", line 13

    print'<table border="1">'

                            ^

SyntaxError: invalid syntax

>>> 


xiaoxiaomengmeng
浏览 3925回答 1
1回答

人笨嫌刀钝

python3中print的语法是这样的print('xxxxxxxxxxx')
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python