How does the onlooker write a Python loop and use the memory to the extreme?

0 Preface When it comes to processing loops, we are used to using for, while, etc., for example, printing the characters in each list in turn:   lis = ['I', 'love', 'python'] for i in lis:     print(i) I love python When the number of bytes of the printed content is small, it can be printed after all the bytes are loaded into memory. There ...

Added by gurechan on Wed, 11 Dec 2019 03:57:18 +0200

Python functions and operations

Bowen structureCustom functionVariable scopePython built-in functions I. function Functions in Python are collections of statements and expressions. There is no limit to the use of functions, just like other values in Python. For reusable code, you need to write a custom function for reuse. Functions can be divided into nonparametric functio ...

Added by rubbertoad on Sun, 08 Dec 2019 19:43:06 +0200

Training iris data sets with several classification models

Several common classification algorithms are used to train iris data, and K-fold cross validation method is used for evaluation K-fold cross validation: sklearn.model_selection.KFold(n_splits=k, shuffle=False, random_state=None) Idea: the training / test data set is divided into n ﹣ splits mutually exclusive subsets, one of whi ...

Added by Minor Threat on Sat, 30 Nov 2019 23:09:31 +0200

Exercise: object oriented

1. Create an Auto class, including the number of tires, car color, body weight, speed and other attributes, and create instances through different construction methods. At least the car should be able to accelerate and slow down Another car class, CarAuto, inherits Auto, adds air conditioning and CD attributes, and re implements methods to cove ...

Added by catnip_uk on Thu, 28 Nov 2019 14:53:11 +0200

How to create and start Java threads?

There are four common ways to create threads in Java. 1. Override the run() method of the Thread class. There are two forms of expression: 1) the new Thread object anonymously overrides the run() method package constxiong.concurrency.a006; /** * new Thread Object anonymous override run() method, start thread * @author ConstXiong ...

Added by jkmcgrath on Wed, 27 Nov 2019 16:39:13 +0200

Kotlin Core Syntax: Introduction to kotlin, Type System

Kotlin is a static language that runs on Java virtual machines, Android s, and browsers. It is 100% compatible with JAVA. If you are familiar with Java, you will find that Kotlin still uses the classic JAVA collection framework, in addition to its own standard libraries. Introduction to kotlin First try the Kotlin code.The Book class contains t ...

Added by NeilB on Mon, 25 Nov 2019 05:33:10 +0200

python Foundation (28):isinstance, issubclass, type, reflection

1. isinstance and issubclass 1.1 isinstance isinstance(obj,cls) checks whether obj is a cls like object class Foo(object):   pass obj = Foo() isinstance(obj, Foo) Example: class Base(object):   pass class Foo(Base):   pass obj1 = Foo() print(isinstance(obj1,Foo)) # Check that the first parameter (object) is an instance of the ...

Added by lordrain11 on Fri, 15 Nov 2019 22:40:07 +0200

Examples of recursive function calls and anonymous function lambda's summation of 1-100 and calculation factorial examples in Python

1. Script example of recursively listing files in directoryTo list the files in the directory, you can do the following: os.listdir() In [1]: import os In [4]: os.listdir('/root') Out[4]: ['.tcshrc', '.bash_history', '.bashrc', 'ENV', '.cache', '.config', '.cshrc', '.bash_logout', 'python', '.ssh', 'shell', '.bash_profile', '.ip ...

Added by thesimon on Fri, 01 Nov 2019 06:26:20 +0200

Making wheels by hand: realizing a simple dependency injection

Making wheels by hand: realizing a simple dependency injection (1) Intro In the previous article, I mainly introduced the overall design and general programming experience of dependency injection. This article will start to write code and start to implement its own dependency injection framework. Class diagram Let's review the class diagram men ...

Added by kunalk on Tue, 29 Oct 2019 19:52:02 +0200

Java basic tutorial -- File class, Paths class, Files class

Class File The File class is in the java.io package. IO stands for input and output, input and output. Represents files and directories that are not platform related. You can create, delete, rename, but you cannot access the file content. Constants in the File class: import java.io.File; public class TestFileConst { public static void mai ...

Added by ++Sti++ on Mon, 28 Oct 2019 20:52:15 +0200