导航:首页 > 编程语言 > pythongetinfo

pythongetinfo

发布时间:2024-10-12 02:22:15

python pycurl有哪些参数

#!/usr/bin/env python2
#encoding=utf8
import pycurl
import StringIO
# 安装pycurl到http://pycurl.sourceforge.net/这里去找.
# 在windows安装的话http://pycurl.sourceforge.net/download/ , 看你使用的版本决定下载那个,我在 windows使用的是python2.4, 所以下载 pycurl-ssl-7.15.5.1.win32-py2.4.exe 。
def test(debug_type, debug_msg):
print "debug(%d): %s" % (debug_type, debug_msg)
def postFile(url,post_file):
#print pycurl.version_info()
#这个函数创建一个同 libcurl中的CURL处理器相对应的Curl对象.Curl对象自动的设置CURLOPT_VERBOSE为0, CURLOPT_NOPROGRESS为1,提供一个默认的CURLOPT_USERAGENT和设置CURLOPT_ERRORBUFFER指向一个私有的错误缓冲区.
c = pycurl.Curl() #创建一个同libcurl中的CURL处理器相对应的Curl对象
b = StringIO.StringIO()
#c.setopt(c.POST, 1)
c.setopt(pycurl.URL, url) #设置要访问的网址 url = "http://www.cnn.com"
#写的回调
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1) #参数有1、2
#最大重定向次数,可以预防重定向陷阱
c.setopt(pycurl.MAXREDIRS, 5)
#连接超时设置
c.setopt(pycurl.CONNECTTIMEOUT, 60) #链接超时
# c.setopt(pycurl.TIMEOUT, 300) #下载超时
# c.setopt(pycurl.HEADER, True)
# c.setopt(c.HTTPHEADER, ["Content-Type: application/x-www-form-urlencoded","X-Requested-With:XMLHttpRequest","Cookie:"+set_cookie[0]])
#模拟浏览器
c.setopt(pycurl.USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)")
# c.setopt(pycurl.AUTOREFERER,1)
# c.setopt(c.REFERER, url)
# cookie设置
# Option -b/--cookie <name=string/file> Cookie string or file to read cookies from
# Note: must be a string, not a file object.
# c.setopt(pycurl.COOKIEFILE, "cookie_file_name")
# Option -c/--cookie-jar Write cookies to this file after operation
# Note: must be a string, not a file object.
# c.setopt(pycurl.COOKIEJAR, "cookie_file_name")
# Option -d/--data HTTP POST data
post_data_dic = {"name":"value"}
c.setopt(c.POSTFIELDS, urllib.urlencode(post_data_dic))
#设置代理
# c.setopt(pycurl.PROXY, ‘http://11.11.11.11:8080′)
# c.setopt(pycurl.PROXYUSERPWD, ‘aaa:aaa’)
#不明确作用
# c.setopt(pycurl.HTTPPROXYTUNNEL,1) #隧道代理
# c.setopt(pycurl.NOSIGNAL, 1)
#设置post请求, 上传文件的字段名 上传的文件
#post_file = "/home/ubuntu/avatar.jpg"
c.setopt(c.HTTPPOST, [("textname", (c.FORM_FILE, post_file))])
# 调试回调.调试信息类型是一个调试信 息的整数标示类型.在这个回调被调用时VERBOSE选项必须可用
# c.setopt(c.VERBOSE, 1) #verbose 详细
# c.setopt(c.DEBUGFUNCTION, test)
# f = open("body", "wb")
# c.setopt(c.WRITEDATA, f)
# h = open("header", "wb")
# c.setopt(c.WRITEHEADER, h)
# print "Header is in file 'header', body is in file 'body'"
# f.close()
# h.close()
# c.setopt(c.NOPROGRESS, 0)
# c.setopt(c.PROGRESSFUNCTION, progress)
# c.setopt(c.OPT_FILETIME, 1)
#访问,阻塞到访问结束
c.perform() #执行上述访问网址的操作
print "HTTP-code:", c.getinfo(c.HTTP_CODE) #打印出 200(HTTP状态码)
print "Total-time:", c.getinfo(c.TOTAL_TIME)
print "Download speed: %.2f bytes/second" % c.getinfo(c.SPEED_DOWNLOAD)
print "Document size: %d bytes" % c.getinfo(c.SIZE_DOWNLOAD)
print "Effective URL:", c.getinfo(c.EFFECTIVE_URL)
print "Content-type:", c.getinfo(c.CONTENT_TYPE)
print "Namelookup-time:", c.getinfo(c.NAMELOOKUP_TIME)
print "Redirect-time:", c.getinfo(c.REDIRECT_TIME)
print "Redirect-count:", c.getinfo(c.REDIRECT_COUNT)
# epoch = c.getinfo(c.INFO_FILETIME)
#print "Filetime: %d (%s)" % (epoch, time.ctime(epoch))
html = b.getvalue()
print(html)
b.close()
c.close()

㈡ 用python编写的一个学生成绩管理系统

# -*- coding: cp936 -*-
class StuInfo:
def __init__(self):
self.Stu=[{"Sno":"1","Sname":"姓名","ChineseScore":64,"MathsScore":34,"EnglishScore":94,"ComputerScore":83},
{"Sno":"2","Sname":"姓名","ChineseScore":44,"MathsScore":24,"EnglishScore":44,"ComputerScore":71},
{"Sno":"3","Sname":"姓名","ChineseScore":74,"MathsScore":35,"EnglishScore":74,"ComputerScore":93},
{"Sno":"4","Sname":"姓名","ChineseScore":94,"MathsScore":54,"EnglishScore":24,"ComputerScore":73}]
self.attribute={"Sno":"学号",
"Sname":"姓名",
"ChineseScore":"语文成绩",
"MathsScore":"数学成绩",
"EnglishScore":"英语成绩",
"ComputerScore":"计算机成绩"
}
def _add(self):
'''添加'''
singleInfo={}
for i in self.attribute:
if "Score" in i:
singleInfo[i]=int(raw_input(self.attribute[i]+"\n"))
else:
singleInfo[i]=raw_input(self.attribute[i]+"\n").strip()
self.Stu.append(singleInfo)
print "添加成功OK"
for i in singleInfo:
print i,"=",singleInfo[i]

def _del(self):
"""删除学号为Sno的记录"""
Sno=raw_input("学号:\n")
self.Stu.remove(self.__getInfo(Sno))
print "删除成功OK"

def _update(self):
"""更新数据"""
Sno=raw_input("学号\n").strip()
prefix="修改"
updateOperate={"1":"ChineseScore",
"2":"MathsScore",
"3":"EnglishScore",
"4":"ComputerScore"}
for i in updateOperate:
print i,"-->",prefix+self.attribute[updateOperate[i]]
getOperateNum=raw_input("选择操作:\n")
if getOperateNum:
getNewValue=int(raw_input("输入新的值:\n"))
record=self.__getInfo(Sno)
record[updateOperate[getOperateNum]]=getNewValue
print "修改"+record["Sname"]+"的"+str(updateOperate[getOperateNum])+"成绩=",getNewValue,"\n成功OK"

def _getInfo(self):
"""查询数据"""
while True:
print "1->学号查询 2->条件查询 3->退出"
getNum=raw_input("选择:\n")
if getNum=="1":
Sno=raw_input("学号:\n")
print filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
elif getNum=="2":
print "ChineseScore 语文成绩;","MathsScore 数学成绩;","EnglishScore 英语成绩;","ComputerScore 计算机成绩;"
print "等于 ==,小于 <, 大于 > ,大于等于 >=,小于等于<= ,不等于!="
print "按如下格式输入查询条件 eg: ChineseScore>=60 "
expr=raw_input("条件:\n")
Infos=self.__getInfo(expr=expr)
if Infos:
print "共%d记录"%len(Infos)
for i in Infos:
print i
else:
print "记录为空"
elif getNum=="3":
break
else:
pass
def __getInfo(self,Sno=None,expr=""):
"""查询数据
根据学号 _getInfo("111111")
根据分数 _getInfo("EnglishSorce>80")"""
if Sno:
return filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
for operate in [">=",">","<=","<","==","!="]:
if operate in expr:
gradeName,value=expr.split(operate)
return filter(lambda record: eval( repr(record[gradeName.strip()])+operate+value.strip()) ,self.Stu)
return {}

def _showAll(self):
"""显示所有记录"""
for i in self.Stu:
print i

@staticmethod
def test():
"""测试"""
_StuInfo=StuInfo()
while True:
print "1->录入数据 2->修改数据 3->删除数据 4->查询数据 5->查看数据 6->退出"
t=raw_input("选择:\n")
if t=="1":
print "录入数据"
_StuInfo._add()
elif t=="2":
print "修改数据"
_StuInfo._update()
elif t=="3":
print "删除数据"
_StuInfo._del()
elif t=="4":
print "查询数据"
_StuInfo._getInfo()
elif t=="5":
print "显示所有记录"
_StuInfo._showAll()
elif t=="6":
break
else:
pass
if __name__=="__main__":
StuInfo.test()

㈢ 用Python编写班级档案管理系统

# -*- coding: cp936 -*-
class StuInfo:
def __init__(self):
self.Stu=[{"Sno":"1","Sname":"姓名","ChineseScore":64,"MathsScore":34,"EnglishScore":94,"ComputerScore":83},
{"Sno":"2","Sname":"姓名","ChineseScore":44,"MathsScore":24,"EnglishScore":44,"ComputerScore":71},
{"Sno":"3","Sname":"姓名","ChineseScore":74,"MathsScore":35,"EnglishScore":74,"ComputerScore":93},
{"Sno":"4","Sname":"姓名","ChineseScore":94,"MathsScore":54,"EnglishScore":24,"ComputerScore":73}]
self.attribute={"Sno":"学号",
"Sname":"姓名",
"ChineseScore":"语文成绩",
"MathsScore":"数学成绩",
"EnglishScore":"英语成绩",
"ComputerScore":"计算机成绩"
}
def _add(self):
'''添加'''
singleInfo={}
for i in self.attribute:
if "Score" in i:
singleInfo[i]=int(raw_input(self.attribute[i]+"\n"))
else:
singleInfo[i]=raw_input(self.attribute[i]+"\n").strip()
self.Stu.append(singleInfo)
print "添加成功OK"
for i in singleInfo:
print i,"=",singleInfo[i]

def _del(self):
"""删除学号为Sno的记录"""
Sno=raw_input("学号:\n")
self.Stu.remove(self.__getInfo(Sno))
print "删除成功OK"

def _update(self):
"""更新数据"""
Sno=raw_input("学号\n").strip()
prefix="修改"
updateOperate={"1":"ChineseScore",
"2":"MathsScore",
"3":"EnglishScore",
"4":"ComputerScore"}
for i in updateOperate:
print i,"-->",prefix+self.attribute[updateOperate[i]]
getOperateNum=raw_input("选择操作:\n")
if getOperateNum:
getNewValue=int(raw_input("输入新的值:\n"))
record=self.__getInfo(Sno)
record[updateOperate[getOperateNum]]=getNewValue
print "修改"+record["Sname"]+"的"+str(updateOperate[getOperateNum])+"成绩=",getNewValue,"\n成功OK"

def _getInfo(self):
"""查询数据"""
while True:
print "1->学号查询 2->条件查询 3->退出"
getNum=raw_input("选择:\n")
if getNum=="1":
Sno=raw_input("学号:\n")
print filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
elif getNum=="2":
print "ChineseScore 语文成绩;","MathsScore 数学成绩;","EnglishScore 英语成绩;","ComputerScore 计算机成绩;"
print "等于 ==,小于 <, 大于 > ,大于等于 >=,小于等于<= ,不等于!="
print "按如下格式输入查询条件 eg: ChineseScore>=60 "
expr=raw_input("条件:\n")
笭工蒂继郦荒垫维叮哩 Infos=self.__getInfo(expr=expr)
if Infos:
print "共%d记录"%len(Infos)
for i in Infos:
print i
else:
print "记录为空"
elif getNum=="3":
break
else:
pass
def __getInfo(self,Sno=None,expr=""):
"""查询数据
根据学号 _getInfo("111111")
根据分数 _getInfo("EnglishSorce>80")"""
if Sno:
return filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
for operate in [">=",">","<=","<","==","!="]:
if operate in expr:
gradeName,value=expr.split(operate)
return filter(lambda record: eval( repr(record[gradeName.strip()])+operate+value.strip()) ,self.Stu)
return {}

def _showAll(self):
"""显示所有记录"""
for i in self.Stu:
print i

@staticmethod
def test():
"""测试"""
_StuInfo=StuInfo()
while True:
print "1->录入数据 2->修改数据 3->删除数据 4->查询数据 5->查看数据 6->退出"
t=raw_input("选择:\n")
if t=="1":
print "录入数据"
_StuInfo._add()
elif t=="2":
print "修改数据"
_StuInfo._update()
elif t=="3":
print "删除数据"
_StuInfo._del()
elif t=="4":
print "查询数据"
_StuInfo._getInfo()
elif t=="5":
print "显示所有记录"
_StuInfo._showAll()
elif t=="6":
break
else:
pass
if __name__=="__main__":
StuInfo.test()

㈣ python 字符串处理 SQL查询语句

>>> base = """("%(k)s" = '%(v)s')"""
>>> print ' and '.join([base % dict(k=k, v=v) for k,v in dict(name='tim', email='[email protected]').items()])

("email" = '[email protected]') and ("name" = 'tim')
>>>

另外: 强烈建议不采用拼接字符串的方式定义SQL,而是采用参数

㈤ 遥感数字图像定量反演的方法

遥感数字图像可以用Google earth engine python API来实现定量反演。

用基于GEE的pythonAPI,主要实现以下内容:

站点数据和遥感影像匹配。

利用机器学习/深度学习模型进行匹配数据的训练。

将训练的模型用于GEE上的影像数据,实现参数反演结果成图。

提取影像的metedata,作为模型的输入数据。

注意,直接采用img.get( )得到的是computerobject这种类型的结果,无法在机器学习模型中输入和计算,应加上.getInfo()。

总结如下:

反演,在人工智能领域又称为人工智能反演(inversion with artificial intelligence),是指能够模仿人类智能的计算机程序系统即人工智能专家系统,它具有学习和推理的功能。例如模拟退火最优化系统、人工神经网络系统等。

在反问题求解过程中应用人工智能的方法技术,引导局部或全局寻优,这种反演方法称为人工智能反演技术。

㈥ python顺序表

本问题回答如下:你可以根据自己的需求稍微改动一下
# -*- coding: cp936 -*-
class StuInfo:
def __init__(self):
self.Stu=[{"Sno":"1","Sname":"姓名","ChineseScore":64,"MathsScore":34,"EnglishScore":94,"ComputerScore":83},
{"Sno":"2","Sname":"姓名","ChineseScore":44,"MathsScore":24,"EnglishScore":44,"ComputerScore":71},
{"Sno":"3","Sname":"姓名","ChineseScore":74,"MathsScore":35,"EnglishScore":74,"ComputerScore":93},
{"Sno":"4","Sname":"姓名","ChineseScore":94,"MathsScore":54,"EnglishScore":24,"ComputerScore":73}]
self.attribute={"Sno":"学号",
"Sname":"姓名",
"ChineseScore":"语文成绩",
"MathsScore":"数学成绩",
"EnglishScore":"英语成绩",
"ComputerScore":"计算机成绩"
}
def _add(self):
'''添加'''
singleInfo={}
for i in self.attribute:
if "Score" in i:
singleInfo[i]=int(raw_input(self.attribute[i]+"\n"))
else:
singleInfo[i]=raw_input(self.attribute[i]+"\n").strip()
self.Stu.append(singleInfo)
print "添加成功OK"
for i in singleInfo:
print i,"=",singleInfo[i]

def _del(self):
"""删除学号为Sno的记录"""
Sno=raw_input("学号:\n")
self.Stu.remove(self.__getInfo(Sno))
print "删除成功OK"

def _update(self):
"""更新数据"""
Sno=raw_input("学号\n").strip()
prefix="修改"
updateOperate={"1":"ChineseScore",
"2":"MathsScore",
"3":"EnglishScore",
"4":"ComputerScore"}
for i in updateOperate:
print i,"-->",prefix+self.attribute[updateOperate[i]]
getOperateNum=raw_input("选择操作:\n")
if getOperateNum:
getNewValue=int(raw_input("输入新的值:\n"))
record=self.__getInfo(Sno)
record[updateOperate[getOperateNum]]=getNewValue
print "修改"+record["Sname"]+"的"+str(updateOperate[getOperateNum])+"成绩=",getNewValue,"\n成功OK"

def _getInfo(self):
"""查询数据"""
while True:
print "1->学号查询 2->条件查询 3->退出"
getNum=raw_input("选择:\n")
if getNum=="1":
Sno=raw_input("学号:\n")
print filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
elif getNum=="2":
print "ChineseScore 语文成绩;","MathsScore 数学成绩;","EnglishScore 英语成绩;","ComputerScore 计算机成绩;"
print "等于 ==,小于 <, 大于 > ,大于等于 >=,小于等于<= ,不等于!="
print "按如下格式输入查询条件 eg: ChineseScore>=60 "
expr=raw_input("条件:\n")
Infos=self.__getInfo(expr=expr)
if Infos:
print "共%d记录"%len(Infos)
for i in Infos:
print i
else:
print "记录为空"
elif getNum=="3":
break
else:
pass
def __getInfo(self,Sno=None,expr=""):
"""查询数据
根据学号 _getInfo("111111")
根据分数 _getInfo("EnglishSorce>80")"""
if Sno:
return filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
for operate in [">=",">","<=","<","==","!="]:
if operate in expr:
gradeName,value=expr.split(operate)
return filter(lambda record: eval( repr(record[gradeName.strip()])+operate+value.strip()) ,self.Stu)
return {}

def _showAll(self):
"""显示所有记录"""
for i in self.Stu:
print i

@staticmethod
def test():
"""测试"""
_StuInfo=StuInfo()
while True:
print "1->录入数据 2->修改数据 3->删除数据 4->查询数据 5->查看数据 6->退出"
t=raw_input("选择:\n")
if t=="1":
print "录入数据"
_StuInfo._add()
elif t=="2":
print "修改数据"
_StuInfo._update()
elif t=="3":
print "删除数据"
_StuInfo._del()
elif t=="4":
print "查询数据"
_StuInfo._getInfo()
elif t=="5":
print "显示所有记录"
_StuInfo._showAll()
elif t=="6":
break
else:
pass
if __name__=="__main__":
StuInfo.test()
希望本次回答对你的提问有所帮助谢谢

㈦ python如何实现多行数字自增

#!/usr/bin/envpython
#coding:utf-8

defgetinfo(num):
i=1
str_num="1"
for_inrange(num):
str_num+='0'
foriinrange(1,int(str_num)):
for_inrange(num):
print"test%s"%str(i).zfill(num)
getinfo(3)

阅读全文

与pythongetinfo相关的资料

热点内容
澳门使用什么app 浏览:558
如何查看php服务器账户密码修改 浏览:146
数据文件入库加密 浏览:574
逢八进一计算法 浏览:617
如何借朋友的网盘会员解压 浏览:326
股票入门pdf 浏览:953
吉祥如意APP是什么 浏览:937
隐藏软件能二层加密吗 浏览:424
51单片机低功耗模式 浏览:312
亿启骑牛高抛低吸源码 浏览:339
php集成java 浏览:87
pythongetinfo 浏览:512
玩具解压制作教程 浏览:909
双卡服务器如何理解 浏览:806
用枚举算法寻找问题多解说课 浏览:990
安卓手机如何更换指纹 浏览:876
蔬果压缩片排油 浏览:903
如何禁止ie服务器设置 浏览:891
python难还是ruby难 浏览:397
怎么新建一个程序文件夹 浏览:634