1. Sort a list of numbers from small to large, then write to the file, then read the contents of the file from the file,And then reversed, in the next line appended to the fileList = [67, 234, 35, 14, 18, 6, 9, 5]List.sort ()With open (' 20171030 ',
python download, install, editor, first program1:python with the 3.6.3 version (currently the latest version) can be downloaded directly from the Python official web (Windows version): https://www.python.org/downloads/windows/.2:windows environment
1. Definition of functionDefinition: A function is a collection of a set of statements by a name (function name) encapsulated, in order to execute this function, just call its function name. The characteristics are as follows:
Reduce
String Common operations
JudgeVariable. EndsWith ("trailing character"): determines the ending string.Variable. Isalnum (): Determines whether it is a letter or a number.Variable. Isalpha (): Determines whether it is an English
1. BackgroundZephyr Project Flash and RAM space is tight, with very strong optimization requirements.The premise of optimization is to quantify the target, then how to quantify the amount of flash and RAM usage?After quantification, the
Python Common File Operations Summary: fromrandom Import Shuffle determine if the folder is valid:ifNot Os.path.isdir (targetDir): Print'Invalid target directory: {}'. Format (targetDir) sys.exit (2) to determine if a folder exists:ifnot
Import OS‘‘‘This module is Db_handler, as the database connection engine(This is primarily a JSON file)‘‘‘def file_db_handler (conn_params): Db_path = '%s\%s '% (conn_params["path"],conn_params["name"]) Return Db_pathdef db_handler
########## #使用线程完成多任务 ################ from Import Thread Import Time # 1. If multiple threads are executing the same function, they will not affect each other, each of which is a def Test (): print(" ----drank too much last night and drank
1. Concept of module and package 1.1Module: After a lot of code, it is not easy to maintain in a. py file, splitting the code into multiple. py files, each of which is a module.Package: After more modules, it is also easy to duplicate the name, each
To demonstrate the use of URLLIB3, we will download two files from a website here.First, you need to import the URLLIB3 library:import urllib3The source URLs for these two files are:url1 =
1. Slicing operations 1.1 slicing a list or tuple 1.1.1 using the range functionl=[0,1,2,3,4,5,6,7,8,9]R=[]# range function, does not contain the number of terminationsFor I in range (2,5):R.append (L[i])1.1.2 Using the slice operatorL[0:3],
5. FunctionsThe Python function code block starts with the DEF keyword; The function contents begin with a colon and are indented. * Note: python, strings, tuples, and numbers are objects that cannot be changed, while list,dict are objects that can
' 1.int 2.str 3. Meta-zu tuple Tu = (' name ') TU1 = (' name ',) Print (Tu,type (TU)) Print (Tu1,type (TU1)) 4. List When you loop through a list, if you delete some or some elements in the loop, the number of elements in the list changes,
Flag = "======================= Adorner ============================="#定义的装饰器函数# def outer (func):# def inner ():# print (' Plus adorner ')# r = func ()# return R# return Inner## @outer# def F1 ():# print (' original function ')"""The essence of
Python determines whether it is a prime number or a prime number. python Prime Number
A natural number greater than 1 cannot be divisible by other natural numbers (prime numbers) except 1 and itself (2, 3, 5, 7, etc ), in other words, this number
Python logging module and pythonlogging ModulePython logging Module 1. Simply print logs to the screen
ImportLogging
Logging. debug ('This is debug message')
Logging.info ('This is info message')
Logging. warning ('This is warning message')
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service