Model layer - 9: Query set API

This section details the API of the query set, which is based on the following model, the same as the one in the previous section: from django.db import models class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def __str__(self): # __unicode__ on Python 2 return sel ...

Posted by Sneo on Sat, 02 May 2020 12:02:14 -0700

python 3.x learning note 5 (decorator)

1. Decorator: Function in essence, which is to add additional functions to other functions principle: 1) the source code of the decorated function cannot be modified 2) the call mode of the decorated function cannot be modified 2. Realize the knowledge reserve of decorators: 1) function is "variable" 2) higher order function A. ...

Posted by jpopuk on Sat, 02 May 2020 07:48:51 -0700

hiho week 169 simple calculator

Time limit: 10000ms Single point time limit: 1000ms Memory limit: 256MB describe Writing a program can complete the basic four operations with brackets. Where division (/) is an integral division and is rounded to 0 when dividing by a negative number. (the default division of C/C++/Java is to round to 0, and the default divisio ...

Posted by zander213 on Sat, 02 May 2020 04:09:10 -0700

Sesame HTTP: setup of crawler Selenium+Chrome agent

Micro blog login limits the number of errors... In addition, a large number of Cookie accounts are blocked and need to be removed from the Cookie pool... Need to use a proxy... Rogue Baidu has been special for most of the day??? It turns out that Google can solve the problem in minutes? What else can baidu do besides sell fake medicine The Sele ...

Posted by Arbitus on Sat, 02 May 2020 01:10:23 -0700

Bulk merge PDF files with Python (bookmarking)

On the Internet, I found several softwares that combine pdf, which are not very easy to use. Generally, they don't have the function of bookmarking. I went to find the script of python merging pdf, and found that there was no function of bookmarking. So I wrote a small tool by myself, using PyPDF2, the code is as follows: #!/usr/bin/env py ...

Posted by gwolff2005 on Sat, 02 May 2020 00:12:31 -0700

Login of python beginners' account

requirement: The user name and password are correct, indicating that the login is successful, Enter the wrong password three times to lock the account. Start: Use two files: Password account file File format: jason    23456 tom       56789 tang      345687 boke      567890 Password lock file format: tom jason flow chart Code Used Dictionary: d ...

Posted by Templar on Fri, 01 May 2020 23:41:50 -0700

Python database connection pool DBUtils

DBUtils is a module of Python used to implement database connection pool, and allows thread safe packaging of non thread safe database interface. Two modes of connection: Create a connection for each thread. Even if the thread calls the close method, it will not close. It just puts the connection back into the connec ...

Posted by jyhm on Fri, 01 May 2020 22:16:17 -0700

Class foundation and data attribute (python)

Reference connection: http://www.cnblogs.com/wilber2013/p/4677412.html class Student(object): count = 0 books = [] def __int__(self,name,age): self.name = name self.age = age pass #do nothing, an empty statement, ensures the integrity of format and semantics Data properties In the above Student class, &quo ...

Posted by Codein on Fri, 01 May 2020 18:47:40 -0700

Prefetch count -- prefetch quantity

1, Foreword As mentioned earlier, if multiple consumers subscribe to messages in the same Queue at the same time, the messages in the Queue will be shared equally among multiple consumers. At this time, if the processing time of each message is different, it may cause some consumers to be busy all the time, while others will soon finish the wor ...

Posted by thewabbit1 on Fri, 01 May 2020 17:37:52 -0700

Python: business card management system

String and list, I tried to write a very simple business card management system, Xinmeng tries, Don't spray, I stole the function of modifying business card, Because I don't know how to modify the strings in the list by defining subscripts and then subscripts My idea is to delete the business card that the user is going to modify, and then add ...

Posted by lisaNewbie on Fri, 01 May 2020 14:58:02 -0700