One: Output
With Print plus a string, you can output the specified text on the screen. For example, enter ' Liu Yan Liang '
print ' Liuyanliang '
printStatements can also be followed by multiple strings, separated by a comma "," to be connected to a string of outputs:
print ' Liu ', ' Yan ', ' Liang '
printEach string will be printed sequentially, and a comma "," will output a space, so the output string is spelled together.
Two: input
Now you can already use print output the results you want. But what if you want users to enter some characters from the computer? Python offers a raw_input , which allows the user to enter a string and store it in a variable. For example, enter the user's name:
>>> name = raw_input()Michael
When you type name = raw_input() and press ENTER, the python interactive command line is waiting for your input. At this point, you can enter any character and then press ENTER to complete the input.
After the input is complete, there is no hint, and the Python interactive command line goes back to >>> status. So where is the content we just entered? The answer is to deposit to name variable. can be directly input name view variable contents:
>>> name‘Michael‘
raw_inputand the print is the most basic input and output below the command line!
Python learning: input/output