Python—11 module

In the process of computer program development, as more and more program code is written, the code in a file will become longer and longer, more and more difficult to maintain. In order to write maintainable code, we grouped many functions into separate files, so that each file contained relatively little code, and many programming languages used this method of organizing code. In Python, a.Py file is called a module (Module).). What are the advantages of using modules? The biggest benefit is greatly improving the maintainability of the code. Second, writing code does not need to start from s...

C# reflection – field

C#Reflection – field details         C#The Type and FieldInfo that reflect the public field related classes are reflected. Get related public fields   public FieldInfo[] GetFields();//Get all public field collections   public abstract FieldInfo[] GetFields(BindingFlags bindingAttr);//Gets the type constraint word.  public FieldInfo GetField(string name);//Gets the field of the specified name  public abstract FieldInfo GetField(string name, BindingFlags bindingAttr);//Gets the field of the specified name and constraint. Assign values to object instance fields ...

Notes on obtaining the number of star items that a user has on GitHub

For StarsKeeper development, you need to get the total number of projects that a user has started on GitHub, as shown below. The first thing I thought about was the user-related api, with Authorization Token on the headers, which is actually the API https://api.github.com/user. But this is the case.There are followers and following numbers, but no starred repo. SO After searching, there was a similar problem. The method is very simple, a little hack meaning. Take user hanzichi as an example, request https://api.github.com/users/hanzichi/starred? PerIf you add Authorization Token, then it̵...

P1592 mutual quality

Input: two positive integers n and K, and K positive integers with n are coprime. $n≤10^6,k≤10^8$   You can quote the number of Coprime, and find that there is a cycle. For example, 10 The 1379111317192123 272931333739 of its coprime Horizontal groove section!!!!! The circular section is equal to 4, the difference =10 (n) of each cycle. So… First deal with 1-N and N coprime. Then find K’s loop section. #include<cstdio> #include<iostream> #include<cstring> #include<cctype> #include<algorithm> using namespace std; #define int long long #d...

GridSearchCV cross validation

Code implementation (based on logistic regression algorithm): 1 # -*- coding: utf-8 -*- 2 """ 3 Created on Sat Sep 1 11:54:48 2018 4 5 @author: zhen 6 7 Cross validation 8 """ 9 import numpy as np 10 from sklearn import datasets 11 from sklearn.linear_model import LogisticRegression 12 from sklearn.model_selection import GridSearchCV 13 import matplotlib.pyplot as plt 14 15 iris = datasets.load_iris() 16 x = iris['data'][:, 3:] 17 y = iris['target'] 18 19 20 def report(results, n_top=3): 21 for i in range(1, n_top + 1): 22 candidates = np.flatnonzero(results['ra...