I'm guessing you mean x = "1p"?
You're trying to take an integer value off the front of a string, right?
So if x = "123abc" you want 123, and if x = "10307a10c52" you want 10307, right? I don't know of a function that does this for you in Python, but I can think of some code that would, although it probably isn't very efficient code. You could make a loop that takes larger portions of the string each iteration, tries to convert them to integers with the int() function, and ends when it catches a ValueError. Here it is, for what it's worth:
-
x = "123abc"
-
x_number = 0
-
for i in xrange(1, len(x)):
-
try:
-
x_number = int(x[:i])
-
except ValueError:
-
break
-
print x_number
-
I also googled for "Python, atoi", and found
this archived thread, in which reply #3 has some code that does this too.
Hope this helps.