programmer group

Basic usage of Sequelize

install $ npm install --save sequelize # You also need to install one of the following: $ npm install --save pg pg-hstore // postgreSql $ npm install --save mysql // mysql or mariadb $ npm install --save sqlite3 $ npm install --save tedious // MSSQL Establish connection const Sequelize = require('sequelize') const sequelize = new Sequelize(db.database, db.user, db.password, { //Table Name User Name Password host: db.host, //address port: db.port, //port dialect: 'mysql', //Database...

programmer group

Strings and lists in Python

Character string 1. Definition of strings: a = 'westos' b = "what's" c = """ //User Management System 1.Adding users 2.delete user Three.show user .... """ print(a) print(b) print(c) [29] 2. Characters of strings: s = 'hello' # Index: 0 1 2 3 4 index starts from 0 print(s[0]) print(s[1]) # Take out the last character print(s[4]) print(s[-1]) # s[start:stop:step] from satrt to END-1 # step print(s[0:3]) print(s[0:4:2]) [30] # Display all characters print(s[:]) # Display the first three characters print(s[:3]) #...

programmer group

Efficient Utilization of Python's Built-in Data Structure

0x00: Create a one-click multi-value dictionary Dictionary is a variable container in Python, which usually appears in this form:d = {key1:value1, key2:value2, key3:value3}Python does not specify the type of value in a dictionary, so if you want a key in a dictionary to correspond to multiple values, just put those values in a container such as a list. student = { 'a': [76, 54, 82], 'b': [92, 67, 88] } To facilitate the creation of such a dictionary, you can use the defaultdict class in the collections module. Generally, an error will...