test.py
test2.py
wordscounter.py
test.py
1 class Person:
2 def __getitem__(self, key):
3 return key
4
5
6 p = Person()
7 s = Person()
8
9 Person.name = "Unknown"
10 p.name = "Jack"
11 p.gender = "Male"
12 p.age = 30
13 s.name = "Rose"
14 s.gender = "Female"
15
16 print Person
17 print p
18 print s
19 print Person.name
20 print p.name
21 print p.gender
22 print p.age
23 print s.name
24 print s.gender
25
26 print s[0]
multiply99.py
datediff.py
accept.py
1 import socket
2 import threading
3 import select
4 allsocks = []
5
6 def acc():
7 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
8 sock.bind("", 2555)
9 sock.listen(5)
10 while 1:
11 newsock, remote = sock.accept()
12 allsocks.append(newsock)
13
14
15 newthread = threading.Thread(target = acc)
16 newthread.start()
17
18 while 1:
19 (rdsocks,,) = select.select(allsocks, [],[], 0.1)
20 for s in rdsocks:
21 msg = s.recv(100)
autosubmit.py
1 import glob
2 import urllib
3 import re
4 reobject = re.compile('(?P<hello>[0-9]*)\.(?P<ext>.*)')
5 for filename in glob.glob('[0-9]*.*'):
6 mo = reobject.match(filename)
7 if mo:
8 prob, ext = mo.groups()
9 else:
10 continue
11 if ext.lower() in ['c']:
12 language = 0
13 elif ext.lower() in ['cc', 'cpp']:
14 language = 1
15 else:
16 continue
17 params = urllib.urlencode({'language':language, 'user_id':'wzuacm',
18 'passwd':'wzuacm', 'prob_id':prob, 'source':open(filename).read() })
19 print params
20 request = urllib.urlopen("http://acm.zju.edu.cn/submit_process.php", params)
21 request.read()
22 request.close()