How to convert a list of multiple integers into a single integer?
问题 How do I convert a list in Python 3.5 such as: x=[1, 3, 5] to an int of 135 (a whole int)? 回答1: If you have a list of int s and you want to join them together, you can use map with str to convert them to strings, join them on the empty string and then cast back to int s with int. In code, this looks like this: r = int("".join(map(str, x))) and r now has the wanted value of 135 . This, of course, is a limited approach that comes with some conditions. It requires the list in question to contain