1. Basic
R ': Original string
POW and round are built-in functions
2. Sequence General operation:
Index: d[]
Shard: [:]
Add: d+[]
Multiplication: [1,2]*3
Member judgment: in
Available functions: Len
Interface test, the discovery interface return content is Uncodie type but contains Chinese. Output prompt error when printing with print:Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 733-738:ordinal not in range
1. Use placeholders to reserve locations for real values and specify the formatPrint ("I ' m%s.") I ' m%d year old "% (' AAA ', 18))We can also use dictionaries to pass real values. As follows:Common format characters%s: string%d: decimal integer%b:
Defining a variable inside a function is called a local variable, and it can only be used inside a functionOutside of the function, you cannot use theVariables defined outside the function are global variables and can be used within a function.If
First, scene reproductionIn Python, when we open a file, for the robustness of the code, we usually consider some exceptions, such as:Try : = Open ('/path/data') = ccfile.readlines () ccfile.close () except IOError: log.write ('no data
List built-in functions
#!/usr/bin/env python# -*- coding:utf-8 -*-# class list (object):# "" "# list () -> new empty list# list (iterable) -> new list initialized from iterable ' s items# "" "## def append (Self, p_
a standard data type1 shaping and floating-point shapesThe difference between python2.* and python3.* about integral type python2.* on 32-bit machines, the number of integers is 32 bits, the value range is -2**31~2**31-1, that is -2147483648~21474836
a first line of Python code1. Interpreter: Instant debug Code, code cannot be saved permanently2. File: Permanently save codeTo create a new file hello.py in the D:\python_test\ directory, write the following codePrint (' Hello World ')Execute hello.
1: Write A For loop that iterates through each character with an indexmsg= ' Hello Egon 666 'msg = ' Hello Egon 666 'j = Len (msg) for I in range (0,j-1):Print (Msg[i])2: Write a while loop and use the index to iterate through each charactermsg= '
1: Write A For loop that iterates through each character with an indexmsg= ' Hello Egon 666 '2: Write a while loop and use the index to iterate through each charactermsg= ' Hello Egon 666 '3: msg= ' Hello Alex ' in the replacement of Alex into SB4:
# # # #编写一个程序, in a folder, find all the files with the specified prefix, such as spam001.txt,spam002.txt , and locate the missing number (for example, presence spam001.txt and Spam003.txt, but there is no spam002.txt). Let the program rename all
1 First use Python to complete the simple output, run as follows:Python and C are similar, but different, Python development is fast, the language is concise, I am so comparative studyOutput: print+ space + ' What to output ', must be in English
Failure, even with the Firefox see headers, parameters are not exactly the same, crawling out of the page, but it is not to give data, try to disable JS, and then see the cookie (JS is no cookie), with this cookie crawl, or not, separated by time to
1. Case conversionJudging a strings.isalnum () #所有字符都是数字或者字母 s.isalpha () #所有字符都是字母 s.isdigit () #所有字符都是数字 s.islower () #所有字符都是小写 s.isupper () #所有字符都是大写 S. Istitle () #所有单词都是首字母大写, like the title S.isspace () #所有字符都是空白字符, \ t, \ n
123456
first, the function1, the function of the use of the scene and definitionBefore the use of function programming, we have been oriented to procedural programming, the accumulation of statements resulting in a large number of code duplication, thus,
1. What is a variable?It's actually a name for the Data. In Python you don't want to care about the data type, because it helps you to recognize it when you're assigned a Value.2. When creating a variable, a space is created in memory, and the
How to Use python to draw various graphics and python to draw graphics
1. Environment
System: Windows 10Python version: python3.6.1Library used: matplotlib, numpy
2. Several Methods for the numpy library to generate random numbers
import numpy as
Python: crawlers (crawling blog Park News) and python Crawlers
Preface
Speaking of python, the first response may be crawlers ~
I have read some python knowledge these two days and can't help but want to write a simple crawler trainer, JUST DO
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