[Tutor] Change a text string from a list and change it into an integer number.(WinXP/py2.6.2/Beginner)
Shashwat Anand
anand.shashwat at gmail.com
Fri Nov 6 04:57:46 CET 2009
import time
def katt(d):
date0 = d.split("_")[0]
if date0 == "cyear":
return int(time.strftime("%Y"))
else:
return int(date0)
print katt("cyear_11_05")
print katt("1984_11_05")
l0nwlf-Arena:l0nwlf$ python katt.py
2009
1984
http://codepad.org/RBjKmNcA
Hope this helps !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091106/46ade018/attachment-0001.htm>
More information about the Tutor
mailing list