Unicode characters can be processed as a generalization, starting with python1.6.
one, several common coding formats.1.1, ASCII, expressed in 1 bytes.
1.2, UTF-8, expressed in 1 to three bytes, the ASCII code occupies only 1 bytes, ASCII encoding is a subset of UTF-8.
1.3, UTF-16, expressed in 2 bytes, in Python, the meaning of Unicode is UTF-16.
Second, the Python
Python's C language see the appropriate PEP guide 1.
This document, along with Pep 257 (specification of document Strings), is adapted from Guido's original Python style Guide, while adding some of Barry's style guide 2.
This normative guide evolves over time, and as the language itself changes, the conventions of the past are eliminated.
Many projects have their own coding specifications, in the event of
Talking about the coding process of Python crawling web pages, talking about python crawling code
Background
During the mid-autumn festival, A friend sent me an email saying that when he was crawling his house, he found that the Code returned from the webpage was garbled and asked me to help his adviser (working overtime during the Mid-Autumn Festival, really ded
Summary of coding knowledge in python, python Encoding
Problem
During normal work, I encountered the following error:
UnicodeDecodeError: 'ascii' codec can't decode byte
It is common that everyone has encountered it. So I decided to organize and learn python encoding.
Basic knowledge
In python2.x, there are two data ty
Python coding knowledge learning notes, python learning notes
Python coding knowledge learning notes
>>> A = 'medium' ===> a is an encoded binary. It adopts the default encoding method of the operating system, similar to byte.
>>> S = U' '===> s is a unicode type, 32-bit
PEP 8 Python Code specification collationClick hereGoole Python style Guide Chinese versionClick hereLet's have a choice.Because the article is not original, so only address, to everyone cause trouble, forgive me.Network is not good, there is no official Python address, we can look for their own. I did not find in the offline document, click Pep 8 will not jump,
Unicode formatS1.encode ("UTF8") successS2.encode ("UTF8") success3. When Chinese is present:S1 = "Hello"--utf-8 encoded. Why is it not ASCII under Linux? Does the ASCII mean Chinese?It must have been converted for utf-8.S2 = u "Hello"S1.encode ("UTF8") errorS2.encode ("UTF8") successWorkaround:First, convert this utf-8 code to Unicode-encoded objectsAnd then into the utf-8.S1.decode ("UTF8"). Ecode ("UTF8") successful Linux Chinese as "Utf-8"Equivalent to S1 and back again, itself is the Utf-8
This book I read the electronic version, feel good, a total of 20 chapters, the book is as follows:This book is designed to enable you to learn Python as quickly as possible so that you can write programs that work correctly-games, data visualizations, and WEB applications-while mastering basic programming knowledge th
Strings are the most commonly used data types in Python, and many times you use characters that do not belong to the standard ASCII character set, and the code is likely to throw Unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xc4 In position 10:ordinal not in range (128) exception. This anomaly is easy to come across in Python, especially in python2.x, a problem that puzzles beginners. However, if
Before the formal explanation, let's give you a reference: poke hereThe contents of this article refer to this information, and to summarize, in order to avoid my summary is not perfect, or say what wrong place, there are questions about where you can see the above article.Let's start with the coding problem in Python, first of all, we'll see what the coding is.1
Add by Zhj: This is Douban friends finishing PEP8, is a simple version of PEP8, because the original PEP8 content too much, so it is recommended to read this article first, and then see PEP8 Chinese TranslationOriginal: http://www.douban.com/note/134971609/Decided to start the Python road, using spare time, for more in-depth study of Python. Programming languages are not art, but work or tools, so it is nec
Python Coding knowledge
Coding Introduction
Kinds
Storage units
1. Introduction to CodingEncoding is the process of converting information from one form or format to another, also known as a code abbreviation for a computer programming language. The text, numbers, or other objects are digitally digitized by a predetermined method, or the inf
From the Woodpecker community Python Coding Rule
---hoxide first translation dreamingk proofreading release 040724
---xyb re-typesetting 040915
---zoomquiet moinmoin landscaping 050610
Coding style conventions when developing with PythonSource:PEP 008 Style Guide for Python codeDownlo
the file is encoded internally.1) ANSI: The encoding of the file is two bytes "D1 CF", which is the "strict" GB2312 coding, which also implies that GB2312 is stored in the big head way.2) Unicode: Encoding is four bytes "ff fe 4E", where "FF fe" indicates a small head mode of storage, the true encoding is 4E25.3) Unicode Big endian: The encoding is four bytes "Fe FF 4E 25", wherein "FE FF" indicates that the head is stored in the way.4) UTF-8: The en
. Provide complete websocket support, which makes HTML5 's games and so on convenient.Like the long rotation is the use of WebSocket, but WebSocket mobile phone support is not very good,Some time ago had to use timed Ajax to send a large number of requests, expect the mobile browser quickly catching up
Use Tornado to create a simple book introduction pageWell, let's take a look at the code implementation of this b
The high-speed landing practice of Python Coding style guide
Machine and human strengths, such as coding style Check this can be self-active work should be handed over to the machine, so this article helps you in a few minutes to achieve the coding style of self-active inspection.
1. What are the famous
process of developing a Python program, there are three aspects of coding involved:
Code for Python Program Files
Encoding of the Python Program Runtime Environment (IDE)
Python program reads the encoding of external files and Web pages
that compatible with all nations I can use utf-8 ah, can, completely normal work, the reason is not sure that Unicode is more efficient than utf-8 AH (uicode fixed with 2 byte encoding, utf-8 need to calculate), but Unicode is more wasted space, yes, This is a way to use space for time, and storage to the hard disk, or network transmission, all need to turn Unicode into utf-8, because the transmission of data, the pursuit of stability, high efficiency, the smaller the amount of data transmissio
accelerate flask
5. Provide a complete websocket support, which makes HTML5 games, etc. to facilitate.Like the long rotation is the use of websocket, but WebSocket phone support is not very good,Some time ago had to use timed Ajax to send a large number of requests, look forward to the mobile browser quickly catching up
Use Tornado to create a simple book introduction pageOkay, now, let's take a look at the code implementation of the
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.