Use the built-in function raw_input () built-in function, which reads the standard input and assigns the read data to the specified variable. We can use the Int () built-in function to convert a user-entered string to an integer:
>>> user = Raw_input ("Enter Login Name:")
Enter Login Name:root
>>> print "Your Login is:", user
Your Login Is:root
The above example can only be used for text input, and below is an example of entering a numeric string (and converting the string to an integer):
>>> number = Raw_input ("Now Enter a number:") now enter a number:1024
>>> print "Doubling your number:%d"% (int (number) * 2)
Doubling your number:2048
In Python, in addition to the INT function, there are several functions for converting types to each other.
Float: Converts a string or integer to a floating-point number
STR: Converting a number to a string
CHR: Converts ASCII values to ASCII characters
Hex: Converts an integer to a 16-binary string
Long: Converts a string to a long shape
Oct: Converting integers to eight-binary strings
Ord: Converting ASCII strings to ASCII values
Python: Using built-in functions to convert strings to integers