旅游网站建设色彩搭配表,wordpress 主题模板下载,做食品网站需要什么,wordpress 内容可以是表格吗以前的客户地址比较乱#xff0c;现在想提取出省份城市#xff0c;
开始了解分词技术#xff0c;后发现python有这样的库
cpca提取地址挺不错#xff0c;可以从垃圾地址中提取省市区以及区号。 文章会用fastapi搭建服务端
通过post调用cpca#xff0c;提取来了后#…以前的客户地址比较乱现在想提取出省份城市
开始了解分词技术后发现python有这样的库
cpca提取地址挺不错可以从垃圾地址中提取省市区以及区号。 文章会用fastapi搭建服务端
通过post调用cpca提取来了后返回给用户。 我的环境win7 python3.10
win7安装python3.10前面有文章介绍也有安装包 首先安装
pip install fastapi 正常情况下现在可以使用fastapi了而我比较波折
装完后写demo运行fastapiimport那就出错了
后来我不断降级 代码
from fastapi import FastAPI
from fastapi import FastAPI, Request, Body
import uvicorn
from hashlib import md5
import cpcaapp FastAPI()app.get(/)
def read_root():return {Hello: 你好}app.get(/bar)
async def read_item(name: str,age: int 28):return {name:name,age:age}app.post(/soso)
async def read_item(foo: int Body(1,title描述,embedTrue),age: int Body(..., le120, title年龄, embedTrue),name: str Body(..., regex^xiao\d$, embedTrue)):return {foo: foo, age: age, name: name}app.post(/cpca)
async def read_item(timestamp: str Body(min_length13,title时间戳,embedTrue),key: str Body(...,min_length32, title秘钥, embedTrue),content: str Body(...,min_length2, embedTrue)):key2 timestampcontentkey2 md5(key2.encode(encodingUTF-8)).hexdigest()key2 md5(key2.encode(encodingUTF-8)).hexdigest()if keykey2:df cpca.transform([content])if df.size 0:return {status:False}else:province df.省[0]city df.市[0]district df.区[0]areacode df.adcode[0]if provinceNone:province if cityNone:city if districtNone:district if areacodeNone:areacode return {status:True,content: content,province:province, city:city, district:district, areacode:areacode}else:return {status:False}if __name__ __main__:uvicorn.run(app, host0.0.0.0, port8001) 服务如果能正常运行则可在服务器部署python环境
或者用pyinstaller打包成exe放服务器运行打包时
需要注意cpca有个资源文件夹要一起打包。。。。