You can see this writing: #-*-coding: UTF-8-*-this is used to illustrate your Python source
ProgramThe encoding used for the file. By default, your program needs to be written in ASCII code, but if you write Chinese in it, the python interpreter
The character string is unicode encoded in Python. Therefore, during encoding and conversion, Unicode is usually used as the intermediate encoding, that is, the other encoded strings are decoded into Unicode, then, convert the Unicode encoding
Floating point type:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
>>>
A
=
B
=
4.3
>>>
A
Is
BTrue
>>>
C
=
4.3
>>>
A
Is
CFalse
>>>
D
=
1.3
+
3.0
Example 1: List
Obtain the list length Len (list), append the list element list. append (), list sort list. Sort (), and delete the list element del list [Index].
Code
Code highlighting produced by Actipro CodeHighlighter
I hope you can give me more advice. Please contact me if you have any mistakes or different opinions.
Let's talk about everything. Let's talk about what we 've encountered. It's different from me. Let's just look at it.
Capture information. Use
Comparison between extend and append in list in Python
What's the difference? If you append a list to another list, you add the new list as a single extra list to the original, thus makingthe original list just one longer with an item that is
This website is a great tutorial:
Http://sebug.net/paper/python/ch02.html
This article only records learning problems.
1. Windows and Linux
Python is installed by default in Linux. In Windows, you need to install and configure environment
Variables declared inside the class definition, but not inside a method are class or static variables:
>>> class MyClass: ... i = 3 ... >>> MyClass.i 3
As @ Daniel points out, this creates a class-level "I" variable, but this is distinct from
Constant:
All the letters of a constant name are uppercase, and each word is connected by an underscore, as shown in figureWhite = 0 xffffffThis_is_a_constant = 1
Variable:
1. Common variables:All lowercase letters, which are connected by
PythonDictionary operations
Python provides a variety of dictionary-based operations. Because the dictionary is a container, the built-in Len function can use the dictionary as a single parameter to return the number of items (key/value pairs) in
Script:
#!/usr/bin/python
dict={"a":"apple","b":"banana","o":"orange"}
print "##########dict######################"
for i in dict:
print "dict[%s]=" % i,dict[i]
print "###########items#####################"
for
Module
I. Introduction
The module is basically a file that contains all the functions and variables you define. To reuse a module in other programs, the module File name must be.pyIs the extension.
For example:
#! /Usr/bin/python # filename:
A.Dict. fromkeys (s)
S is a list or tuples...
Use the element in s as the dictionary key. The default value is none. You can also specify an initial value. The code example is as follows:
myDict = dict.fromkeys('hello', True)for k in myDict.keys():
When you want a function to receive parameters in the form of tuples or dictionaries, there is a special method that uses the * and * prefixes respectively.This method is particularly useful when the function needs to obtain variable numbers of
1. Use * in Python to represent variable parameters, similar to the C language... however, one or more parameters must be included before variable parameters in C language.
Def funcd (a, B, * C): print a print B print "length of C is: % d" % Len (c)
I checked a lot on the Internet and used struct for packaging and package settlement. please google the content, but it is not the result I want, I just want to directly convert a string into byte []. I don't need to define every location so
Baseexception all Exception base classes + -- systemexit Python interpreter request exit + -- keyboardinterrupt User Interrupt execution (usually press Ctrl + C) + -- generatorexit generator (generator) when an exception occurs, the exit is notified.
Add #-*-coding: UTF-8-*-to the file -*-
Utf8 Encoding Error for the Template
The simplest way is to go to Bom.
Use DM to open the page and remove Bom. If not, click menu modify page properties title/encoding modify Unicode (UTF-8) Save. OK
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