项目功能代码

来源:互联网 发布:网络培训有多少真的 编辑:程序博客网 时间:2024/06/05 20:19

项目功能代码

标签(空格分隔): 项目 功能模块 Python JavaScript SQL sh脚本


  • 项目功能代码
      • 远程访问其他项目后台函数
      • 实现文本框中输入数字跳转对应页面

远程访问其他项目后台函数

# -*- coding=utf-8 -*-import sys import datetimeimport decimalfrom decimal import Decimalimport httplibimport urllibimport simplejson as jsonreload(sys)sys.setdefaultencoding('utf-8')__time__ = '2016-10-01'__author__ = '吴问涛'def getftprate(starday,endday):    conn=httplib.HTTPConnection('155.104.1.145',3002)    data=json.dumps({'curve_type':"fundYieldCurve",'end_date':endday,'rateadjusttype':u"不调整",'start_date':starday}) # 传入函数所需参数    conn.request('POST','/yieldcurve/query_2',data,{'Content-Type':'application/json'})  # 函数的Url路径    res=conn.getresponse()    resultxx = json.loads(res.read()) # 远程取到值    ftprate=resultxx["data"]["result2"]["rate_2"]    ftprate=decimal.Decimal(ftprate).quantize(decimal.Decimal('0.01'))    ftprate=str(ftprate)+'%'    return ftprate

实现文本框中输入数字,跳转对应页面

__from__ = 'Baidu'//如下代码可以实现,在文本框里输入数字,可以跳到对应的页面,比如输入1,会跳到1.html:<input type="text" id="txt" /><input type="button" value="输入数字跳转" onclick="Cmd()" /><script>    function Cmd(){        window.location.href = document.getElementById("txt").value + ".html";    }</script>
原创粉丝点击