One line of code to get it done: li_int = [map(int, e) for e in li]
The complexity of the conversion is linear and can be tolerated if the amount of data is not particularly large. If there is really a lot of data, whichever one is used will be used for conversion.
Traverse, since every number needs to be converted, in theory the conversion program must visit each element at least once
Same idea as above, use
map
Use list parsing, but still need to traverse.
As mentioned above, because every element is accessed and then converted, let’s traverse it. . .
If the values are used in scattered places, convert each time a value is used and replace the original value.
One line of code to get it done:
li_int = [map(int, e) for e in li]
The complexity of the conversion is linear and can be tolerated if the amount of data is not particularly large. If there is really a lot of data, whichever one is used will be used for conversion.