(1) Python first knowledge and variables

First acquaintance with python

  Articles by Daniel Lecturer: http://www.cnblogs.com/wupeiqi/articles/5433925.html

Features of python

  You can write web pages and background functions. Low execution efficiency and high development efficiency (compared to java)


Kind of python

  JPython: python developed by java, running python code is converted to java code first, and then executing
  IronPython: Python language implemented on .NET and Mono, the execution method is the same as above
  JavaScriptPython: python developed by javascript, the execution method is the same as above
  RubyPython: analogy, same as above
  CPython: Cpython is our commonly used python, it is developed by C, the most stable and powerful python
  pypy: this is Python developed with CPython. The most efficient python, but the function is not perfect and stable

python execution flow

  Install python to the OS, write the file according to the python rules, hand the file to the python interpreter, read the file content to the memory, execute the action, and get the execution result

variable

  It can only consist of uppercase and lowercase letters, numbers, and underscores, but cannot start with a number;

       And the following built-in keywords cannot be declared as variables:

['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']

 

 

A simple example:

# !/usr/bin/env python specifies the interpreter 
# -*- coding:utf-8 -*- #Encoding, py2 must be specified, otherwise garbled characters 
time = " 20180422 " 
username = input( ' Enter username: ' )
password = input( ' Enter password: ' )
 if username == " erbiao "  and password == " erbiaopasswd " :
     print ( " Login successful " )
     print (time)

 

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324726740&siteId=291194637