Attributeerror: 'int' Object Has No Attribute 'replace'
I am wondering why I have this error when I run this code: # Ask user input # Find out network device id for network device with ip or hostname, index 3 is device id # In the loop
Solution 1:
If you're using Python3.x input
will return a string,you can try to debug your code to check the type of user_input
or
print(type(user_input))
If you're using Python2.x input
maybe is not a good way for your code
because input
function evaluates your input.If your input is 1 2
you will get SyntaxError: invalid syntax
,and if your input is 1
,and it will get int
object,this is why you got the error.
I suggest raw_input
because raw_input
takes exactly what the user typed and passes it back as a string.
You can read this
Hope this helps.
Post a Comment for "Attributeerror: 'int' Object Has No Attribute 'replace'"