How to concatenate two integers in Python?

前端 未结 14 1972
南旧
南旧 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:19

    A rough but working implementation:

    i1,i2 = 10,20
    num = int('%i%i' % (i1,i2))
    

    Basically, you just merge two numbers into one string and then cast that back to int.

提交回复
热议问题