class PhoneNumber(): def __init__(self,number): self.a=number[1:4] self.b=number[6:9] self.c=number[10:14] def __str__(self): return "(%s) %s-%s"%(self.a,self.b,self.c) def test(): print #newNumber=raw_input("Enter phone number in the form. (123) 456-7890: \n") #phone=PhoneNumber(newNumber) #print "The phone number is:",phone if __name__=="__main__": test()
时间: 2024-10-27 13:03:23