Python QuickStart (1)

Source: Internet
Author: User
Tags natural string

From: Laboratory building

Http://python.usyiyi.cn/python_278/tutorial/index.html

http://woodpecker.org.cn/abyteofpython_cn/chinese/

PYTHON-PEP8 Official Code Style guide

Google-python Code Style Guide

The Python source code format check under Linux:

$ sudo apt-get update

$ sudo apt-get install PEP8

PEP8 Check File source code format error:

$ PEP8 file_name.py

Source code: Use UTF8 encoding by default:

#-*-Coding:utf-8-*-

In a BSD-like Unix system, Python can execute directly as a shell, specifying files and schemas in the first line of the script file:

#! /usr/bin/env python

======================================================

String:

"" "or" "" "": using three quotation marks, you can indicate a multiline string. You can use single and double quotation marks freely in three quotes.

Escape character \: Escaped ' & ' & \

In a string, a single backslash at the end of the line indicates that the string continues on the next line instead of starting a new row.

Natural strings: If you want to indicate certain strings that do not require special handling such as escape characters, then you need to specify a natural string. Natural strings are specified by prefixing the string with R or R.

For example r"Newlines are indicated by \n" .

Be sure to use a natural string to process the regular expression . Otherwise, you will need to use a lot of back slashes.

Unicode string: Use non-English text, plus u or u before the string.

Cascading strings: Put two strings in a literal order, and they will be automatically cascaded by Python.

For example, ‘What\‘s‘ ‘your name?‘ it will be automatically converted "What‘s your name?" .

Python QuickStart (1)

Related Article

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.