[Tutor] Reformatting phone number
Dotan Cohen
dotancohen at gmail.com
Wed Aug 20 22:43:32 CEST 2008
I have a small script (linux) that takes a phone number as an argument:
#!/usr/bin/env python
import sys
number = '+' + sys.argv[1]
....
However, if the first digit of the phone number is a 0 then I need to
replace that 0 with "972". I can add the "972", but how do I remove
the leading "0"?
For instance, this code:
#!/usr/bin/env python
import sys
if sys.argv[1][0] == 0:
number = '+972' + sys.argv[1]
else:
number = '+' + sys.argv[1]
Turns the phone number "0123" into "9720123" but I need "972123". How
is this done? Better yet, where in the fine manual would I find this?
Thanks in advance.
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ä-ö-ü-ß-Ä-Ö-Ü
More information about the Tutor
mailing list