I. Standard template using built-in module SYS#hello. py file#!/usr/bin/env Python3#-*-Coding:utf-8-*-#本文件使用utf-8 encoding' A test module ' #任何模块代码的第一个字符串都被视为模块的文档注释, does not print output__author__ = ' Michael Liao ' #作者名Import SYS #导入模块sysdef test
Under the specified path, searching for the specified content contained in the Excel file, you first need to traverse the specified path to get the absolute/relative path of all Excel files under that path, and then read the contents of Excel,
#迭代器#dir () to see which functions are defined inside an object or class.# Print (dir (int))# Print (dir (list))# tu = (1,)# Print (dir (TU))#__iter__ () Gets an iterator for an iterative objectLST = [1,2,3,4,5,6,7,8,9]it = lst.__iter__ ()#__next__ (
Basic information for Python's Logging module logging:L By default Python's logging module prints to the console, showing only logs greater than or equal to warning levelL Log level: critical > Error > Warning > Info > Debug > NotSetBasic components
Objective:Regardless of learning the language is hoping to make the actual things, the actual thing is certainly the project, do not say that everyone knows to learn programming language must do project.Here's a list of 70 Python combat projects,
Learning Python soon, just learned that the PASS keyword is not aware of the specific role of pass, check the network to explain the pass only the function of the coding structure, or can not understand what the pass in the code of the specific role.
1:strip () method,remove spaces at the beginning or end of a string
>>> a = "a b C"
>>> A.strip ()
' A B C '
2:lstrip () method,remove spaces at the beginning of a string
>>> a = "a b C"
>>> A.lstrip ()
' A B C
First look at the syntax, Python class syntax There are three methods, instance methods, static methods, class methods.#Coding:utf-8classFoo (object):"""class three method syntax form""" defInstance_method (self):Print("is an instance method of
One gevent moduleGevent is a third-party library that makes it easy to implement concurrent or asynchronous programming through Gevent. The main mode used in Gevent is Greenlet, which is a lightweight process that accesses Python in the form of a C
Isinstance is an intrinsic function syntax in Python: Isinstance (object, ClassInfo) If the argument object is an instance of ClassInfo, or object is an instance of a subclass of the ClassInfo class, Returns True. If object is not a given type, the
Code Layout indentation
4 spaces for each level of indentation.
Use vertical implicit indentation in parentheses or use hanging indents.
EXAMPLE:# (vertical implicit indentation) Align Left parenthesis foo = long_function_name (Var_
(I like rainy days, because rainy days I can go back to childhood tread water flowers!) Ha! )2018--July--12th: Cloudy and heavy rain t-tObjectiveI would like to introduce the ultimate crawler, this as long as we can see the naked eye, even in the
In Python, when the code is long, want to see the code execution result in the Pycharm-console console or Python's own idle shell window, print some characters and so on, there are no line breaks between many lines affecting the viewing effect, so
Benefits of Inheritance :1. Build the class in the system to avoid repetitive operation .2, the new class is often based on existing classes, so that you can improve the code reuse degree .Characteristics of inheritance :1, the construction of the
The following values, when used as Boolean expressions, are considered false:False None 0 "" () [] {}The----is the standard value false and none, all types of numbers 0 (including floating-point, long-integer, and other types), empty sequences
0. Import keyboard class keys ()
The keys () class in Selenium provides most of the keyboard manipulation methods, and the Send_keys () method is used to simulate keys on the keyboard.# 导入键盘类 Keys()from selenium.webdriver.common.keys import
the Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.readability counts.Special cases
There are no ternary expressions in other languages in Python, but there are similar implementationsSuch as:A = 1=2ifelse 4The code above is a small demo in Python that implements the three mesh operation, if a>b, K equals 3, otherwise k equals
file operation: Procedure for file operation
Open the file, get the file handle and assign a value to a variable
Manipulating a file with a handle
Close File
The existing files are as followsSomehow, it seems the love I knew
The last time we had a brief look at what a singleton pattern is, we continue to explore today.Last content point this Python design pattern singleton mode (i)
Last time we were talking about the GOF design pattern, which means that a class has
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