Python is indeed a good language. There is no doubt that Python has always been known for its simplicity, convenience, and strength. It is easy to use and easy to use. The standard library and PyPI third-party library have abundant and useful resources, it can quickly solve developers' problems without repeating the wheel. These excellent features have gradually become popular in python over the past few years. In fact, python has been used in foreign countries for several years. The most important thing is that the father of python has gone to Google before, and the promotion of python is very powerful. Like Youtube and Facebook, python is widely used, and more companies are using python, in addition, the community environment is very good. With a large number of open-source software and rich resources, you can quickly get started to solve many problems, so that everyone can respect them. Mr. Liang Changtai, an engineer, recommended me to learn python in. Because I only read some syntax and I didn't have any special entry-level books, I am stranded.
2013 I have to say that it is a year of python. Because the entire python ecosystem is good, websites with large traffic volumes such as Douban and zhihu in China also prove the maturity of python technology in China, in addition, the first entry-level programming course of the MIT computer system switched to python. These factors combined led most people to start learning python frantically. New projects, O & M platforms, and Openstack within a large company make python great. Most of the servers currently use the linux operating system. By default, python is installed in linux. With the powerful processing of python, many O & M personnel can put it easy. This trend also moved from O & M development to python development.
Someone may ask what python can do? To put it bluntly, Python can do anything. C is limited by relatively low-level syntax and has a long development cycle. It is generally used to develop software with high performance requirements. Java focuses on enterprise development, and slow JVM startup speeds make Java unsuitable for developing system management scripts. Python is indeed a versatile player and can be used in many places. Today, many fields are used, such as scientific computing, data analysis, and cloud computing openstack, O & M platform, automated O & M saltstack, and web.
This year, python continues to get worried. A large company offered a price code of 20-30 W, which made me very jealous. In China, python is still used in the direction of python web. You can draw a conclusion from the recruitment website. Django, tornado, Flask, and bottle are all technologies that need to be mastered in most recruitment requirements. Therefore, to learn python and find a good job, you must contact the web framework. Django still occupies more than 90% of the position in recruitment. It seems that there are still many people who prefer this mature framework. It has been tested for a long time and is stable, so many people love to use it, although the Community has seldom talked about Django.
There are still a lot of books on python. If you have no programming experience, you can go to head first python and think python. it is the most straightforward way to get started with "simple python tutorial". Mr. Liao Xuefeng also launched the python tutorial on his official website, which is very good and quick start. Later, you can buy a "python learning manual" and "python core programming" to taste it slowly. Basic Learning these books can improve your python capabilities. The most worrying thing is python web learning, especially for those who have no programming experience. There is really no good tutorial for python web. We can only learn from a framework document, so it will be quite difficult to get started.
Next we will briefly configure the DJango environment to provide you with a simple web.
First install the Django program:
Pip install Django
Then we create the Django project hello
Django-admin.py startproject hello
Go to the hello directory tree to view the structure
.
├ ── Hello project directory
│ ├ ── _ Init _. py treats this directory as an Development Kit
│ ── Settings. py Django setting file
│ ── Url. py route url setting file
│ ── Wsgi. py wsgi configuration file
── Manage. py command tool
Run our Django Server:
Python manage. py runserver
As prompted, you can access http: // 127.0.0.1: 8000/to view the result.
OK! This prompt indicates that the instance has been started successfully!
Then we can see that this is a page showing the server running. We want to modify it to display what we want.
Go to the hello directory, create the views. py file, and type the Code:
- from django.http import HttpResponse
-
- def hello(request):
- return HttpResponse("Hello world ! ")
Good. After the input is completed, save the input. Let's analyze the meaning of this Code. The first line introduces the HttpResponse function in the django project, and then we create a hello function, the hello function uses HttpResponse to return the Hello World string. This Hello World can be changed to the content we want to display on the webpage.
However, the modification does not reach our purpose. We must specify the homepage of the website to this function. Therefore, we need to modify the urls. py file and add the following code:
- from hello.views import hello
-
- urlpatterns = patterns("",
- ('^$', hello),
- )
The first line is introduction. The hello function in the views we just created is to output the desired result.
The next step is to modify the url route. ^ indicates the start and end of $, and the link in the middle is the path to be accessed. For example, ^ admin/$ indicates accessing http: // 127.0.0.1: 8000/admin/Note the final path/). ^ $ indicates accessing http: // 127.0.0.1: 8000. ^ $ Is followed by the hello function, which means to access
Http: // 127.0.0.1: 8000 go to the following hello function, while the hello function returns Hello world! In this way, our page will display Hello world! String.
After saving, refresh the browser and you will see the following results:
OK, a Hello World will be done.
As for the future study, you can read the Django Book based on the above ideas. You have the opportunity to update the blog writing tutorial for Django. Thank you!