Adding a integer at the end of an string in python -
i need generate random ip address starts "192.168.0." need generate random number between 0 , 255 , add end of string, problem don't know how merge integer , string. can me, please?
that's code far:
import random x=random.randint(0,255) randip = '192.168.0.' randip.append(x) print randip
you can use +=
operator appending, you'll need convert x
string first using str
:
import random x=random.randint(0,255) randip = '192.168.0.' randip += str(x) print randip
Comments
Post a Comment