How to concatenate two integers in Python?

前端 未结 14 1969
南旧
南旧 2020-12-15 03:51

How do I concatenate two integer numbers (for example: 10 and 20) in Python to get a returned value of 1020?

14条回答
  •  余生分开走
    2020-12-15 04:34

    The best way to do this in python was given in the accepted answer - but if you want to do this in jinja2 templates - the concatenation operator ~ gives you a neat way of doing this since it looks for the unicode representation of all objects, thus, you can 'concatenate integers' as well.

    That is you can do this (given a=10 and b=20):

    {{ a ~ b }}
    

提交回复
热议问题