[Tutor] (no subject)
wong chow cheok
wong_chow_cheok@hotmail.com
Fri, 06 Apr 2001 16:37:25 +0800
hai chow cheok here again. this is a program i wrote
import re
import urllib
import sys
import string
name={'AS':'Alor Setar '}
if sys.argv[1]==["upper()"]:
p=re.compile('min:\s\s\d\d\s.^*', re.IGNORECASE)
q=re.compile('max:\s\s\d\d\s.^*', re.IGNORECASE)
a=re.compile('whole day^*|morning^*|afternoon^*|evening^*',
re.IGNORECASE)
b=re.compile('fcastimg/(.*?).gif^*', re.IGNORECASE)
html=urllib.urlopen("http://www.kjc.gov.my/cgi-bin/fcastdisplay.cgi?lang=EN&loc="+sys.argv[1]).read()
mintemp=p.search(html)
maxtemp=q.search(html)
time=a.search(html)
con=b.search(html)
print 'Temperature for ',name[sys.argv[1]], mintemp.group(),'and ',
maxtemp.group()
print 'Weather for the day is ',con.groups(1)[0],'in the ', time.group()
else:
print 'all caps'
what i want to do is to make sure my argument variable is in caps. if it is
not it will return an error message. for example when i type in
'python weather AS' it will return the weather output but
'python weather as' will return 'all caps'.
also is there anyway to make sure i don't type the wrong argument variable.
for example if i type
python weather USA, it is caps but out of my range. a few pointers would be
great.
any help is very appreciated.
thank you.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.