Basic operations:
######################### #列表 #############################
alist = [1,2,3,4,5]
#python list is a mutable type. Modifications like the following are legal
#增
alist.append (6)
#删
alist.pop ()
#改
alist[0] =
#查
print (alist[ 0]
to slice a string
String ' xxx ' and unicode string u ' xxx ' can also be viewed as a list, each element being a character. Therefore, strings can also be sliced, but the result of the operation is still a string:
>>> ' ABCDEFG ' [: 3]
' ABC '
>>> '
1. Deep copy and shallow copyObjects in Python are assigned to object reference (memory address) delivery using copy.copy (), you can make a shallow copy of the object, it duplicates the object, but for the elements in the object, still use the
Before sending a message, you need to introduce it in the file header
From Sgmllib import SgmlparserImport SmtplibFrom Email.mime.text import MimetextFrom email. Mimemultipart Import MimemultipartImport datetime
#定义发送邮件的函数 def send_mail
Dictionaries
the dictionary in Python, like the HashMap in Java, exists and operates in the form of key-value pairs, which are characterized by access through keys, not offsets; key-value pairs are unordered; keys and values can be arbitrary;
Python run-time Environment:
Python's runtime was initially created when the Python interpreter was started.
Create process: (1) Create main process object (pyinterpreterstate)
(2) Creating the main thread object (pythreadstate) and placing it
Title: Print out all the "Narcissus number", the so-called "Narcissus number" refers to a three-digit number, its members of the digital cubic and equal to the number itself. For example: 153 is a "narcissus number", because the 153=1 three times
These days began to learn Python, encountered some problems, but also solved some problems.where if __name__ = = ' __main__ ': This sentence estimates that many of the same beginners are superficial understanding.Here's an explanation:
1:__NAME__
Preparing Data: One way is through
Svm_read_problemmethod to directly read the file in the LIBSVM format, returning the category label ([]) and the data ([[]]). Such as: labels, datas =
Svm_read_problem(' filename '), there is a direct Python format,
Today I have a task in my job: There is a text file that holds the names of many countries, one for each line. I'm going to turn this data into a string form in JS to display it in the Web page.First of all subconsciously wrote the following script
Write a very simple script, the function is to write the daily log classification to the specified folder.
Write today's log in my.txt every day, and then save it to a specified folder with a time name
Import shutil
import OS
import Time
class
Use of If,elseIn a Python program, the IF statement implements:score = 95if score >= 90: print(‘Outstanding‘)?If the condition is followed by a conditional judgment statement, if the result of the judgment statement is true, execute if the
One. Python basic data type1. int ==> integer. Used primarily for mathematical operations2. str ==> string, can save a small amount of data and do the corresponding operation3. Bool==> judgment True, false4. list==> stores large amounts of data. Use
#1 creation of a list, denoted by square brackets []name=['Xiaolei','Xiaoman','Lixia','Xiaolei']#2 List of queries, by index value difference, first index to 0#The first of the countdownPrint(name[-1])#second from the
List type of data structureList descriptionadd element to ListTo delete a list elementChange list elementsView list elementsList script operatorsList interception and splicingNested listsList built-in functionsI. Description of the listThe sequence
1. Data type:int: integer str: string, generally does not hold a large number of data bool: Boolean value, used to determine only two values True False list: Lists, used to hold a large amount of data [] to indicate that it can put any data
Read in imageThe read-in image uses Cv2.imread ().Read mode:Cv2. Imread_color: Read a pair of color images, the transparency of the image is ignored, this is the default parameterCv2. Imread_grayscale: Reading into images in grayscale modeCv2.
Class (definition)Static attribute class attributes (variables) are written directly in the class, all uppercaseDynamic property method (function) SelfClass method @classmethodd CLSStatic methods @staticmethod No default parametersThe elective
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