您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 抚顺分类信息网,免费分类信息发布

Python实现CET查分的方法

2025/3/2 14:44:33发布6次查看
本文实例讲述了python实现cet查分的方法。分享给大家供大家参考。具体实现方法如下:
代码如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, urllib2
def cetquery(band, exam_id):
    cetquery version 0.2  2009.2.28
    an exercise program by pt, gz university
    author blog: http://apt-blog.co.cc , welcome to drop by.
#查询连接
    cet = http://cet.99sushe.com/cetscore_99sushe0902.html?t= + band + &id= + exam_id
    print connecting...
    #构造http头
    header = {'referer':'http://cet.99sushe.com/'}
    #第二个参数出现则使用post方式提交
    req = urllib2.request(cet, '', header)
    try:
        data = urllib2.urlopen(req).read()
    except baseexception, e:
        print error retrieving data:, e
        return -1
    if not len(result):
        print error occured. maybe record not existed.
        return -1
    #解码字符串
    result = data.decode(gb2312).encode(utf8)
    res_tu = tuple(result.split(','))
    score_tu = (听力, 阅读, 综合, 写作, 总分, 学校, 姓名)
    print n***** cet %s 成绩清单 ***** % (band)
    print -准考证号: %s % (exam_id)
    for i in range(7):
        print -%s: %s % (score_tu, res_tu)
    print **************************n
    print 准考证号前一位同学: %sn后两位同学分别是: %s、%s % (res_tu[-3], res_tu[-2], res_tu[-1])
    return 0
if __name__ == __main__:
    if (len(sys.argv) != 3) or
        (sys.argv[1] != '4' and sys.argv[1] != '6') or
        (len(sys.argv[2]) != 15):
        print error: 程序参数错误,考试类型(4、6),准考证号长度(15位)
        print nexample:nncetquery.py 4 123456789012345nn
        print cetquery.__doc__
        sys.exit(1)
    statue = cetquery(sys.argv[1], sys.argv[2])
    sys.exit(statue)
希望本文所述对大家的python程序设计有所帮助。
抚顺分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录