Python path-(JS regular expression, template for front-end page, Django Base)

Source: Internet
Author: User

JS Regular expression front-end page template to apply the Django Foundation

JS Regular expression:

1. Define Regular expressions

    • /.../for defining regular expressions
    • /.../g represents a global match
    • /.../i indicates case insensitive
    • /.../m for multi-line matching

Login Registration Verification:

Test

Determine if a string conforms to a specified rule

Rep =/\d+/; (Define rules)

Rep.test (") (the quotation marks must contain letters and numbers to return true, otherwise false)

Rep =/^\d+$/; (Returns true only if it is a pure number, otherwise false)

Exec:

To get the matching data

Example one:

Rep =/\d+/; /\d+/= ' Hehe_99_ddd_33_gg ' "Hehe_99_ddd_33_gg"rep.exec (str) ["["]]rep.exec (str) ["99" ]rep.exec (str) ["99"]
View Code

Example two:

Keyword matches only one keyword at the beginning

Text = "JavaScript is more fun than Java or javabeans!" " JavaScript is more fun than Java or javabeans! " var pattern =/\bjava\w*\b/; undefinedpattern.exec (text) ["JavaScript"]
View Code

Keyword two matches (group match)

Text = "JavaScript is more fun than Java or javabeans!" " JavaScript is more fun than Java or javabeans! " var pattern =/\bjava (\w*) \b/; undefinedpattern.exec (text) ["JavaScript", "Script"]
View Code

Keyword Global match

Text = "JavaScript is more fun than Java or javabeans!" " JavaScript is more fun than Java or javabeans! " var pattern =/\bjava\w*\b/g;undefinedpattern.exec (text) ["JavaScript"]pattern.exec (text) [ "Java"]pattern.exec (text) ["JavaBeans"]pattern.exec (text)nullpattern.exec ( Text) ["JavaScript"]pattern.exec (text) ["Java"]pattern.exec (text)["JavaBeans"] Pattern.exec (text)null
View Code

Keyword Grouping global match

Text = "JavaScript is more fun than Java or javabeans!" " JavaScript is more fun than Java or javabeans! " var pattern =/\bjava (\w*) \b/g;undefinedpattern.exec (text) ["JavaScript", "Script"] Pattern.exec (text) ["Java", "" "]pattern.exec (text) [" JavaBeans "," Beans "]pattern.exec (text) NULL pattern.exec (text) ["JavaScript", "Script"]pattern.exec (text) ["Java", "" "]pattern.exec (text) ["JavaBeans", "Beans"]pattern.exec (text)null
View Code

Multi-line matching: ()

Text = "JavaScript is more fun than Java or \njavabeans!" " JavaScript is more fun than Java or javabeans!" var pattern =/^java (\w*)/gm;undefinedpattern.exec (text) ["JavaScript", "Script"]pattern.exec (text) ["JavaBeans", "Beans"]
View Code

Multi-line matching: (matches only keywords that start on each line, not two group matches)

= "JavaScript is more fun than \njava or javabeans!" " JavaScript is more fun than Java or javabeans!" var pattern =/^java\w*/gm;undefinedpattern.exec (text) ["JavaScript"]pattern.exec (text) [ "Java"]pattern.exec (text)nullpattern.exec (text) ["JavaScript"]pattern.exec ( text) ["Java"]pattern.exec (text)null
View Code

Templates for front-end pages apply:

1, Easyui

Pour css and jquery when you use it

2, jQueryUI

Pour css and jquery when you use it

    

The above two are more scattered functions, in favor of the background management.

3, Bootstrap:

Full-walled comprehensive

4, bootstrap open source template, more on the Internet.

      

Response type
@media

notation: @media (min-width:900px) {  . c2{    background-color:red      }  } I made the page width less than 900 pixels. Back Color turns red
View Code

icons, fonts
@font-face

Specify which font file to use, usually find the icon file inside the Bootsrap, directly copy the code in the HTML, to account for their own HTML.

Bootrap Import Method:

1. Download the Bootrap file.

2. How to Import

Web framework:

Reprinted in the old boy education Silver Corner King's Web architecture article: http://www.cnblogs.com/wupeiqi/articles/5237672.html

Essence:

As we all know, for all Web applications, is essentially a socket server, the user's browser is actually a socket client.

#!/usr/bin/env python#Coding:utf-8  ImportSocketdefhandle_request (client): BUF= CLIENT.RECV (1024) Client.send ("http/1.1 ok\r\n\r\n") Client.send ("Hello, Seven.")  defMain (): Sock=Socket.socket (socket.af_inet, socket. Sock_stream) Sock.bind (('localhost', 8000)) Sock.listen (5)       whiletrue:connection, Address=sock.accept () handle_request (connection) connection.close ()if __name__=='__main__': Main ()
View Code

Mvc
Model View Controller
Database template file Business processing


Mtv

Model Template View
Database template file Business processing

Django Basics:

Preparation environment:

Python Environment variables

PIP environment variable Add

1. Installation

PIP3 Install Django

After the installation is complete, two files will be generated in the PIP scripts directory.

  

  

  Create Project Method One:

1. Create a project

Django-admin.exe Startproject MySite

2. Running the project

Go to the generated project directory,

For example:

CD MySite (this project has a manage.py file, which can be launched with Python)

Python manage.py runserver

    

    

Note: Some people will say, you create this after the creation of a directory with the Pip file, so inconvenient, how to do it, I see below.

Above we created the environment variables for the PIP file, just as Django two files were generated, so that we could build the project into another disk.

    For example: We want to put in the D packing directory.

1. Enter the D plate inside

2. Build the Project

      

It is recommended that you only open a Django project in Pycharm, and do not put it in the same way as other items, so importing the module will mislead your judgment.

    

3, generally a project has a lot of business lines, such as asset management, monitoring, back-office management and so on, so we need a line of business (app), need to be in project to create a separate line of business for an app.

It is recommended that you enter the sibling directory of the project name and then execute the build command.

Python manager.py Startapp CMDB

Python manager.py Startapp OpenStack

Python manager.py Startapp moniter

    

Project File Description:
-MySite # To configure the entire program
-Init
-Settings # configuration file
-URL # URL correspondence relationship
-Wsgi # Follow Wsig specification, Uwsgi + nginx
-manage.py # Managing Django Programs:

Python path-(JS regular expression, template for front-end page, Django Base)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.