博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python发一个GET请求
阅读量:4598 次
发布时间:2019-06-09

本文共 920 字,大约阅读时间需要 3 分钟。

# -*- coding: utf-8 -*-try: 	import httplib2except ImportError:	print('错误:')	print('    httplib2这个库没有找到,程序无法继续运行!')	exit(255)		def network_get_proc(self, use_cache = True):		'''POST动作'''		get_request_str = 'http://192.168.0.54/softlist'	# 请求URL		# print('->%s' % post_request_str)		if use_cache:			h = httplib2.Http('.cache')		else:			h = httplib2.Http('no‐cache')		if use_cache:			response, content = h.request(get_request_str)		else:			response, content = h.request(get_request_str, headers={'cache‐control':'no‐cache'})		print('->status:%d' % response.status)				get_ret = False		if response.status == 200:			get_ret = True			print('INFO:success!')			print('***response***')			print(response)			print('***content***')			print(content.decode('utf-8'))		else:			get_ret = False		return get_ret				# 应用程序入口if __name__ == '__main__':	post_ret = network_get_proc(False)

转载于:https://www.cnblogs.com/hrhguanli/p/3837441.html

你可能感兴趣的文章
Python垃圾回收机制详解
查看>>
{面试题1: 赋值运算符函数}
查看>>
Node中没搞明白require和import,你会被坑的很惨
查看>>
Python 标识符
查看>>
Python mysql 创建连接
查看>>
企业化的性能测试简述---如何设计性能测试方案
查看>>
centos7 安装中文编码
查看>>
POJ - 3683 Priest John's Busiest Day
查看>>
正则表达式start(),end(),group()方法
查看>>
vuejs 学习旅程一
查看>>
javascript Date
查看>>
linux常用命令2
查看>>
狼图腾
查看>>
13、对象与类
查看>>
Sublime Text3 个人使用心得
查看>>
jquery 编程的最佳实践
查看>>
MeetMe
查看>>
IP报文格式及各字段意义
查看>>
(转载)rabbitmq与springboot的安装与集成
查看>>
C2. Power Transmission (Hard Edition)(线段相交)
查看>>