SQL小结
CREATE TABLE STUDENT(
Sno CHAR(8),
Sname CHAR(10),
Ssex CHAR(2),
Sage SMALLINT,
Major CHAR(20));
INSERT INTO STUDENT(Sno,Sname,Ssex,Sage,Major)
VALUES('20100001','CJ','Male',20,'computer')
SELECT A.SnO,Sname,Ssen,Sage,Major,Details
FROM STUDENT A LEFT JOIN AWARD B ON A.Sno=B.Sno
WHERE A.Sno='20100001'
tkinter总结:
import tkinter as tk
window=tk.Tk()
对象名=tk.类(父对象,文本,命令)
对象名.pack()如label,button,entry
window.mainloop()
输入输出总结
x=input("hello")
print(str(i)+' ',end='')
爬虫总结
import requests #需求
from bs4 import BeautifulSoup #BeautifulSoup库解析代码
url='http://www.wsbookshow.com'#定义网址
html=requests.get(url) #引用需求库的获取网址HTML文件
html.encoding="GBK" #编码是GBK
soup=BeautifulSoup(html.text,'html.parser')#分析文件标签划分
print(soup)
htmllist=html.text.splitlines() #把文本分隔
for row in htmllist: #逐行读出
print(row) #输出
循环总结
for i in range(1,10,1):
for j in [1,2,3,4,5,6,7,8,9]:
print(str(i*j)+' ',end='')
print('')
numpy总结
import numpy as np
array=np.array([])#matrix
zero=np.zeros((2,3))#生成的真是0
print(array.shape)#形状
plot总结
import matplotlib.pyplot as plt
listx1=[1,2,3,4,5,6]
listy1=[1,2,3,4,5,6]
plt.plot(listx1,listy1)
plt.show()
pandas总结
import pandas as pd
import numpy as np
dates=np.arange(20170101,20170105)
df1=pd.DataFrame(np.arange(12).reshape((4,3)),index=dates,columns=['a','b','c'])#创建
print(df1)
df2=pd.DataFrame(df1,index=dates,columns=['a','b','c','d','e'])#复制
print(df2)
s1=pd.Series([3,4,6],index=dates[:3])#定义
s2=pd.Series([32,5,2],index=dates[1:])
df2['d']=s1#赋值
df2['e']=s2
print(df2)
数据库
import sqlite3 #导入数据库
conn=sqlite3.connect('test.sqlite') #连接数据库文件,定义句柄conn,注意文件后缀格式是sqlite
cursor=conn.cursor() #获得句柄光标
cursor.execute('CREATE TABLE IF NOT EXISTS table01 ("num" INTEGER PRIMARY KEY NOT NULL , "tel" CHAR(9))')#在光标处输入执行语句,创造表单如果table01不存在,属性num整型唯一关键字非空,tel电话属性是长为9个字符的串
cursor.execute('insert into table01 values(4,"021-7777777")')#在光标处输入执行语句,插进表单table01里面值为(num=4,tel=021-7777777)
cursor2=conn.execute('select * from table01 where num=2') #对句柄执行查找num=2的元组返回光标给cursor2
row=cursor2.fetchone() #读出光标所在行
if not row==None: #如果读出的元组非空
print("{}\t{}".format(row[0],row[1])) #输出该元组的成员
conn.commit() #命令提交
conn.close() #连接关闭