Python basic learning notes (Python environment) and python learning notes
Python first. Summarize the basic knowledge of Python.
I. Understanding Python
First, we need to know that the Python name is used for reference from Monty Python, rather than from what everyone knows. Why should we learn Python? As far as I am concerned, I know that Douban is using and attaches importance to Python. In addition, I want to learn web crawler technology, so I want to learn Python programming. In addition, Yahoo and Google both use Python abroad. Python is worth learning.
2. Hello, World!
First we need to install Python, you can directly access the http://www.python.org/download, download the latest version of Python. Then, you can directly install the agent by following the steps in the installation wizard, which is relatively simple.
After the installation is complete, go to cmd (Windows), enter Python, press the Enter key, and enter the interactive Python interpreter in the dos window. Then we can see the long-awaited HelloWorld.
Don't worry, I 'd like to give you a brief introductionBuild a Python environment.
There are many Python compilers. Here we only introduce two types for your reference:
1), go to the official website to download the Python2.7 compiler IDLE (easy to install, easy to use): https://www.python.org/
After the installation is complete, you can see in the Start Menu:
Click IDLE to open the editor and compile the applet.
2), another Python compiler Pycharm (interface layout and VC6.0 is very similar, start slowly) go to the site download: http://www.jetbrains.com/pycharm/download/ choose your own machine download;
3. Basic Knowledge
First, let's take a look at the numbers, expressions, statements, and simple user input in Python. Here we can be in line with C/C ++ basic programming, the following shows the simple use of Python.
In this case, you must note the differences between Python and C ++. Python provides an operator for implementing the entire division-double diagonal lines.
3.1 notes:# Is used as the annotation identifier in Python.
3.2 string:When print is used to print a string statement, either single or double quotation marks are allowed. However, if there are single quotation marks between strings, we use two output methods: use double quotation marks to output or escape string quotation marks. Correspondingly, if there are double quotation marks between strings, we can use single quotation marks or escape string quotation marks. The escape method is to add a backslash before the quotation marks in the string.
When outputting strings, you can use '+' to concatenate two output strings. Although not many strings are used, they are very useful.
In addition, the repr function creates a string that represents the value in the form of a valid expression. The repr (x) function can also be implemented using 'X' (note that it is a reverse quotation mark.
If we need to enter a long string, We need to wrap it when entering it, And then input it. In this case, we need to use three quotation marks to replace the common single quotation marks.
3.3 differences between input and raw_input functions:Both functions implement user input. However, if the input string contains quotation marks, the input does not reflect the original content. raw_input will save the quotation marks.
Python is an object-oriented high-level programming language, which is easier to understand than C ++ and Java. After learning Java Web, I tried my best to learn Python, and then I had the opportunity to learn advanced crawlers.
I hope you will like this article.
Articles you may be interested in:
- Basic knowledge about Python
- Python BASICS (file input/output built-in dictionary operations)
- Python Study Notes (1) (Basic Environment setup)
- Getting started with Python using the seed () method