首页
Python中文网
在线手册
Python入门
Linux教程
Python高级教程
登录
注册
用户名
Email
自动登录
找回密码
密码
登录
立即注册
扫一扫,访问微社区
只需一步,快速开始
论坛
BBS
Python教程
在线手册
Python入门
Linux教程
Python高级教程
Python函数详解
搜索
本版
帖子
用户
道具
勋章
任务
设置
退出
Python论坛 - 国内最好的Python中文社区
»
论坛
›
技术交流
›
python问答 - 求助悬赏区 Help!
›
求大神帮我看下,我的代码把接收的进EXCEL,修改 ...
返回列表
查看:
857
|
回复:
1
[求助]
求大神帮我看下,我的代码把接收的进EXCEL,修改
谁说女子不如男
当前离线
积分
3
2
主题
3
帖子
3
积分
贫民
贫民, 积分 3, 距离下一级还需 57 积分
贫民, 积分 3, 距离下一级还需 57 积分
积分
3
发消息
谁说女子不如男
发表于 2022-1-14 14:34:33
|
显示全部楼层
|
阅读模式
recvmsg_new.rar
(1003 Bytes, 下载次数: 0)
2022-1-14 14:31 上传
点击文件名下载附件
import
json
from
wsgiref.simple_server
import
make_server
import
urllib.parse
import
re
import
openpyxl
#
导入
openpyxl
模块
def
application
(environ
,
start_resp**e):
if
environ[
"REQUEST_METHOD"
] ==
"GET"
:
return
[
b'get.ok'
,
]
#
定义文件请求的类型和当前请求成功的
code
start_resp**e(
'200 OK'
,
[(
'Content-Type'
,
'application/json'
)])
# environ
是当前请求的所有数据,包括
Header
和
URL
,
body
request_body = environ[
"wsgi.input"
].read(
int
(environ.get(
"CONTENT_LENGTH"
,
0
)))
json_str = request_body.decode(
'utf-8'
)
# byte
转
str
json_str = re.sub(
'
\'
'
,
'
\"
'
,
json_str)
#
单引号转双引号
, json.loads
必须使用双引号
json_dict = json.loads(json_str)
#
(注意:
key
值必须双引号)
print
(json_dict)
return
[
b'welcome'
,
]
if
__name__ ==
"__main__"
:
port =
8888
httpd = make_server(
"0.0.0.0"
,
port
,
application)
print
(
"serving http on port {0}..."
.format(
str
(port)))
httpd.serve_forever()
wb = openpyxl.Workbook()
wb.save(
'excel.xlsx'
)
#
保存文件
#wb = openpyxl.load_workbook('excel.xlsx')
#wb = openpyxl.load_workbook("
数据
.xlsx")
# wb.save("
数据
.xlsx")
#sheet['A1'] = 'msgtype'
#sheet['B1'] = 'wxid'
#sheet['C1'] = 'content'
#sheet['D1'] = 'filepath'
#sheet['E1'] = 'sender'
#sheet['F1'] = 'source'
#sheet['G1'] = 'isphonemsg'
#sheet['H1'] = 'selfwxid'
#for each in range(len(json_dict)):
#sheet['A' + str(each+2)] = str(json_dict[each]['msgtype'])
##sheet['B' + str(each+2)] = str(json_dict[each]['wxid'])
##sheet['C' + str(each+2)] = str(json_dict[each]['content'])
##sheet['D' + str(each+2)] = str(json_dict[each]['filepath'])
##sheet['E' + str(each+2)] = str(json_dict[each]['sender'])
##sheet['F' + str(each+2)] = str(json_dict[each]['source'])
##sheet['G' + str(each+2)] = str(json_dict[each]['isphonemsg'])
##sheet['H' + str(each+2)] = str(json_dict[each]['selfwxid'])
回复
使用道具
举报
谁说女子不如男
当前离线
积分
3
2
主题
3
帖子
3
积分
贫民
贫民, 积分 3, 距离下一级还需 57 积分
贫民, 积分 3, 距离下一级还需 57 积分
积分
3
发消息
谁说女子不如男
楼主
|
发表于 2022-1-15 15:11:13
|
显示全部楼层
顶起来哈
回复
使用道具
举报
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
快速回复
返回顶部
返回列表