Prime numbers (prime number) are also called prime numbers, with an infinite number. There are no more factors than 1 and it itself, otherwise known as composite numbers.
Def _odd_iter ():
n = 1 while
True: n
= n + 2
yield n
def _not_divisible (n):
From random import *
#mktime (tuple) The time tuple is converted to local time
#日期元组说明: Year, month, day, time, minute, second, week, Julian calendar day, daylight
Date1 = (2016,1,1,0,0,0,-1,-1,-1)
time1 = Mktime (date1)
date2 = (2017,1,1,0,0,0,-1,-
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 '
>>> '
Recently learned the next Smtplib module, and then I wrote a message to send the code, running under Windows is no problem, but put on the server running, but has not been running.
At first it was written:
But it's been stuck here since the run:
1)-connector +, for string links, when the definition str= "ABCD", the definition str2= "12345", Str3=str1+str2,print STR3, the result is abcd12345.
2 Len Method, the Len method can be used to calculate the length of the string, such as Len (STR3) =9
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
INI configuration file Deep Master Configparser
1. ini configuration file
If our program does not have any configuration files, such procedures are completely closed, once the program needs to modify some parameters must modify the program code
ProgressBar can show the progress of program running, I mainly use in Jupyter notebook.
In the use of Anaconda installation ProgressBar, there was such a mistake, prompted ProgressBar is Python2.6 use, Python3.5 can not
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
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__
Read Way from forum
Berlin19993428:
I use PIL this library, use OpenCV library also canFrom PIL import ImageImg=image.open ("Demo.jpg")Img_array=img.load ()Then you can read the pixel value by img_array[x,y].In addition img.size view the picture
1, Pandas.read_csv () function, read the file data, because the delimiter is ':: ', pop-up warning as follows
Warning: parserwarning:falling back to the ' Python ' engine because the ' C ' engine does not support regex separators (separators > 1
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
python basic data type int integer str string. Generally do not store large amounts of data bool boolean value. Used to judge. True, False List of lists. Used to hold a large amount of data, [] indicates. It can be loaded with various data
The singleton pattern (Singleton pattern) is a commonly used software design pattern that is primarily intended to ensure that only one instance of a class exists. A singleton can come in handy when you want the entire system to have only one
When a python-drawn chart cannot display Chinese, the following code can be used to solve the problem:Import matplotlibmatplotlib.use ('qt4agg') # Specify default font matplotlib.rcparams['font.sans-serif'= ['Simhei
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