Python method for CET checking _python

Source: Internet
Author: User
Tags ticket

The example of this article is about Python's method of achieving CET checking. Share to everyone for your reference. The implementation methods are as follows:

Copy Code code as follows:
Def cetquery (band, exam_id):
"" "Cetquery version 0.2 2009.2.28
An Exercise program by PT, GZ University
Author blog:, Welcome to Drop by.
CET = "" + band + "&id=" + exam_id
Print "Connecting ..."
Header = {' Referer ': ''}
req = Urllib2. Request (CET, ', header ')
data = Urllib2.urlopen (req). Read ()
Except Baseexception, E:
Print "Error Retrieving data:", E
If not len (result):
Print "Error occured. Maybe The record is not existed.
result = Data.decode ("gb2312"). Encode ("UTF8")
Res_tu = tuple (Result.split (', '))
Score_tu = ("Listening", "reading", "Synthesis", "writing", "Total Score", "school", "name")
Print "n***** CET%s Performance List * * *"% (band)
Print "-Ticket number:%s"% (exam_id)
For I in range (7):
Print "-%s:%s"% (Score_tu, res_tu)
Print "**************************n"
Print "Ticket number before a classmate:%SN after two students are:%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: Program parameter errors, test type (4, 6), ticket number Length (15)"
Print " 4 123456789012345nn"
Print cetquery.__doc__
Sys.exit (1)
Statue = Cetquery (Sys.argv[1], sys.argv[2])
Sys.exit (statue)

I hope this article will help you with your Python programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.