Xwlt
import xlwt
workbook = xlwt.Workbook(encoding='utf-8')
worksheet = workbook.add_sheet('sheet1')
worksheet.write(0,0,'hello')
workbook.save('student.xls')
Sqlite
import sqlite3
conn = sqlite3.connect('test.db')
c = conn.cursor()
sql = '''
insert into company (id,name,age,address,salary)
values (1,'张三',22,'山西',8000)
'''
sql = '''
select * from company
'''
cursor = c.execute(sql)
for row in cursor:
print('id=',row[0])
print('name=',row[1])
print('age=',row[2])
print('address=',row[3])
conn.close()
print("成功")
Flask
from flask import Flask,render_template
import time
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello world!'
@app.route('/1/')
def hello_world2():
a = time.time()
return render_template('index.html',var = a)
@app.route('/welcome/<name>')
def welcome(name):
return 'Hello %s' % name
@app.route('/welcome/<int:id>')
def welcome2(id):
return 'Hello id: %d' % id
if __name__ == '__main__':
app.run()
WordCloud
import jieba
from matplotlib import pyplot as plt
from wordcloud import WordCloud
from PIL import Image
import numpy as np
import sqlite3
conn = sqlite3.connect('test.db')
cur = conn.cursor()
sql = 'select name,address from company'
data = cur.execute(sql)
text = ''
for item in data:
text = text + item[0]
print(text)
cur.close()
conn.close()
cut = jieba.cut(text)
string = ' '.join(cut)
print(len(string))
img = Image.open('639cad061d950a7b7700d56c07d162d9f3d3c9f2.jpg')
img_array = np.array(img)
wc = WordCloud(background_color='white',
mask=img_array,
font_path='CENTURY.TTF')
wc.generate_from_text(string)
fig = plt.figure(1)
plt.imshow(wc)
plt.axis('off')
plt.savefig('word.jpg')
pyinstaller
virtualenv venv
pip3 install pyinstaller
-h 查看帮助
-w 忽略控制台,打包gui软件时使用
-F dist目录中只生成一个exe文件
-p 表示你自己定义需要加载的类库的路径
-D 创建dist目录,里面包含exe以及其他一些依赖性文件(默认,可不添加)
-i 指定打包程序使用的图标文件
pyinstaller-F test.py