2016-02-07 43 views
1

我在Python 3中工作。我想用I/O製作聯繫人應用程序。我想重新運行特定行中的代碼。從特定行重新運行代碼

這樣做的最好方法是什麼?

#Contact 

    Contact=input("Enter Name You Want To Save") 
    f=open(r'C:\Users\Adham\Desktop\we.txt',"w") 
    f.writelines(Contact) 
    f.close() 
    cont=input("write a for another name and l to load the previous save or close the program ") 


    if cont=="a": 
     Contact=input("Enter Name You Want To Save") 
     f=open(r'C:\Users\Adham\Desktop\we.txt',"w") 
     f.writelines(Contact) 
     f.close() 
    elif cont=="l": 
     f=open(r'C:\Users\Adham\Desktop\we.txt',"r") 
     print(f.readlines()) 

    else: 
     print('sorry you made something wrong') 

回答