Python learning notes (1), python learning notes (
>>> print('The quick brown fox', 'jumps over', 'the lazy dog')The quick brown fox jumps over the lazy dog
print()
Each string is printed in sequence, and a comma (,) is used to output a space. Therefore, the output string is combined as follows:
name = input('please enter your name: ')print('hello,', name)
First print the outputplease enter your name:
In this way, the user can enter the name as prompted and gethello, xxx
Output:
Finally, be sure to note that the Python program is case-sensitive. If the case is incorrect, the program reports an error.
If a string contains many line breaks, use\n
It is not easy to read in a row. to simplify it, Python allows'''...'''
Multi-line content
>>> print('''line1... line2... line3''')line1line2line3
Null Value
A null value is a special value in Python.None
.None
Cannot be understood0
Because0
Is meaningful, andNone
Is a special null value.
# -*- coding: utf-8 -*-
> 'Hi, %s, you have $%d.' % ('Michael', 1000000)
If you are not sure what to use,
%s
It always works and converts any data type to a string: