3 lines of python code to realize fake chatbot, Enter the following code in the Python Console.
Python code to realize fake chatbot
while(True): question=input("real person:"); print("fake robot:"+question.strip("???")+"!"); 1 2 3
Learning time is up: Python strip() method The
Python strip() method is used to remove the specified characters at the beginning and end of a string (the default is a space or newline) or character sequence.
Note: This method can only delete the characters at the beginning or end, not the characters in the middle part.
Syntax of strip() method: str.strip([chars]);
Parameters: chars, remove the specified character sequence at the beginning and end of the string.
Return value: Return a new string generated by removing the specified characters at the beginning and end of the string.
str = “123abcrunoob321”
print (str.strip( ’12’ )) # The character sequence is 12
output of the above example is as follows: