项目功能代码

项目功能代码

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


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

# -*- coding=utf-8 -*-
import sys 
import datetime
import decimal
from decimal import Decimal
import httplib
import urllib
import simplejson as json
reload(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>
posted @ 2017-11-30 20:05  SuperScfan  阅读(171)  评论(0编辑  收藏  举报