前言:
此时姐妹们对“python27json”大体比较看重,小伙伴们都想要知道一些“python27json”的相关资讯。那么小编在网上汇集了一些关于“python27json””的相关知识,希望姐妹们能喜欢,同学们快快来学习一下吧!喜欢编程,热爱分享,希望能结交更多志同道合的朋友,一起在学习Python的道路上走得更远!有不懂的问题可以私聊我哦!
本文主要介绍了python 发送json数据操作,结合实例分析了Python使用requests模块发送json数据相关实现技巧,需要的朋友可以参考下,具体操作如下:
代码:
1 # !/usr/bin/env python2 # -*- coding: utf-8 -*-3 import urllib24 import urllib5 import cookielib6 import json7 import httplib8 import re9 import requests10 from lxml import etree11 import StringIO12 import time13 s = requests.session()14 print s.headers15 login_url = ''16 data = {'UserID':'015208','Password':'88888888','ScreenWidth':'1600'}17 # data = urllib.urlencode(data)18 headers = {19 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0'20 }21 response = s.post(login_url, data=data, headers=headers,timeout=10)22 print response23 print '--------------------'24 print response.status_code25 print '--------------------'26 # time.sleep(100)27 print response.content28 print response.headers29 time.sleep(1)30 myurl='","_top'31 print s.get(myurl).content32 myurl=''33 data={"sysHead":{},"appHead":{},"body":{"WORKTYPE":"020","TASKNO":"zhaoyangjian","WORKCONTENT":"zhaoyangjian","WORKHOUR":"10"34 ,"SERIALNO":"2018112100000106","USERID":"015208","REPORTDATE":"2018/11/21","ACCSTATE":"010","INPUTUSERID"35 :"015208","INPUTDATE":"2018/11/21","INPUTORGID":"992200402","UPDATEUSERID":"015208","UPDATEDATE":"2018/11/21","UPDATEORGID":"992200402","ISINUSE":"1","SYS_SAVETMP":"","UPDATED_FIELD":"WORKTYPE,TASKNO,WORKCONTENT,WORKHOUR","novalid":'false'}}36 headers = {37 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',38 'Content-Type': 'application/json'39 }40 print '---------------------------------------------------------'41 print s.post(myurl, data=json.dumps(data), headers=headers).content
PS:这里再为大家推荐几款比较实用的json在线工具供大家参考使用:
在线JSON代码检验、检验、美化、格式化工具:
JSON在线格式化工具:
在线XML/JSON互相转换工具:
json代码在线格式化/美化/压缩/编辑/转换工具:
在线json压缩/转义工具:
觉得文章还不错的话不妨转发收藏点个赞,有任何建议或看法欢迎大家在评论区分享讨论!
我是一名python开发工程师,整理了一套python的学习资料,如果你想提升自己,对编程感兴趣,关注我并在后台私信小编:“08”即可免费领取资料!希望对你能有所帮助!
标签: #python27json