开发者

how to break lines when I concatenate strings in django

hy guys, I needed again of the help of you. Now i want to make a break line when i concatenate strings, i tried to do of this way:

    r['placa_desc'] = PessoaFrota(request,dbcur).get_placa_choices(r.get('placa'))
    if r.get('placa_desc'):
        r['placa'] =   \n + r.get('placa_desc')[0]

but when i try to make this, i got this erro开发者_JAVA百科r:

Exception Value:

unexpected character after line continuation character (views.py, line 250)

Can somebody help me?


You need to quote your \n:

r['placa'] =   \n + r.get('placa_desc')[0]

r['placa'] =   "\n" + r.get('placa_desc')[0]

or python thinks the \ is a continuation character. Try that.


you missed '', it should be:

 r['placa_desc'] = PessoaFrota(request,dbcur).get_placa_choices(r.get('placa'))
    if r.get('placa_desc'):
        r['placa'] =   '\n' + r.get('placa_desc')[0]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜