Python-01. The basic data types and encoding

What is Python:

Python is an easy to learn and powerful programming language. It has a high level data structures, and object-oriented programming can be performed with a simple and efficient manner. Python's elegant syntax and dynamic typing, combined with its explanatory, making it an ideal language for scripting or application development in many areas on most platforms.

Why Python?

  • Python for different platforms (Windows, Mac, Linux, Raspberry Pi, etc.).
  • Python similar to a simple grammar of English.
  • Python's syntax allows developers to write programs with fewer than lines of code in other programming languages.
  • Python interpreter running on the system, which means that the code can be executed immediately after the preparation. This also means that prototyping can be very fast.
  • Python is programmatically, or an object-oriented way to handle functions.

What Python can do?

  • You can create Web applications using Python on the server.
  • Python can be used with software to create a workflow.
  • Python may be connected to the database system. It can also read and modify files.
  • Python be used to process large data and perform complex mathematical operations.
  • Python can be used for rapid prototyping as well as for production-ready software development.
  • It is used for: Web development (server) \ Software Development \ math \ System Script

Python syntax compared to other programming languages:

  • Python is designed for readability, and there are some similarities in English and mathematics affected.
  • Python uses a new line to complete the command, unlike other commonly used programming languages ​​semicolons or parentheses.
  • Python dependent indentation, with spaces defined herein; for example a range of circulating, functions and classes. Other programming languages ​​typically used for this purpose to use curly braces.

Python features:

  • Easy to learn: Python has relatively few keywords, simple structure, grammar and a well-defined learning curve easier.
  • Easy to read: Python code defines more clearly.
  • Easy to maintain: Python's success lies in its source code is fairly easy to maintain.
  • A wide range of standard library: One of the biggest advantages of Python's library is rich, cross-platform, in UNIX, Windows and Macintosh compatible well.
  • Interactive mode: support interactive mode, you can enter from the terminal and get the results of the language, interactive testing and debugging code snippets.
  • Portable: Python can run on multiple hardware platforms and all platforms have the same interface.
  • Scalable: You can add low-level module to the Python interpreter. These modules enable programmers to add or customize their tools more effectively.
  • Database: Python provides an interface to all major commercial databases.
  • GUI Programming: Python GUI support can be created and ported to many system calls.
  • Scalability: Compared shell scripts, Python provides a better structure and support for large programs.

coding:

  • Unicode (Unicode): 32 bit representation . 4 bytes , 2 ** 32;

  • ASCII code : 8 bit indicates 1 byte , 2 ** 8;

  • Py2 default encoded ASCII interpreter;
    Py3 interpreter default encoding UTF-8;

  • Default Py3: at least one byte, a maximum of 4 bytes, 3 bytes 32

  • Py3 interpreter default encoding utf-8,8 bit equals 1 byte (01010101)

  • Py2 or Py3

Add resolve character encoding file header:

# !/usr/bin/env python
# -*- coding:utf-8 -*-

  • Py file format suffix:

Hello.py

Output: print

Print (you want to output the contents of man requires quotes)

Print("Hello,world")

data structure:

    Integer (int):

 

    String (str):

 

    Boolean value (bool):

 

variable:

 

    Variable requirements:

 

    Naming rules:

 

constant:

 

Comment:

 

    One-way

 

    Multi-line

 

Input:

 

Conditional:

    

Guess you like

Origin www.cnblogs.com/cable-run/p/11969880.html