将变量和换行符放入Python的打印语句中

时间:2018-12-02 21:05:23

标签: python

此代码中不断出现语法错误。有人可以在这里看到任何格式错误吗?

for i in range (10,-1,-1):
    b="green bottles sitting on the wall"
    print(i,b,\n,i,b,\n,"And if one green bottle should accidentally fall"\n"There will be",i,b)

2 个答案:

答案 0 :(得分:1)

这是已更正的内容:

$ awk -F'|' 'NR==FNR{a[$1]++;a[$2]++;next} a[$1]*a[$2]>1' file{,}

答案 1 :(得分:0)

应该是这样的:

print(i,b,"\n",i,b,"\n","And if one green bottle should accidentally fall\nThere willbe",i,b)

\n应该是一个字符串。反斜杠(\)字符用于转义具有特殊含义的字符。