2017-03-16 59 views
1
import random 

device = input("What device do you have? Phone or PC(laptop included). If other 
please specify ").upper() 

make = ("") 

model= ("") 

verison = ("") 

memory = ("") 

if device == ("PHONE"): 

make = input ("what make of phone do you have? Iphone or Samsung or other").upper() 
if make == ("IPHONE"): 
    model == input("What model is your iPhone 6 or 7. If other plese spectify") 

if device != ("PHONE") or ("PHONE") or (""): 

    make =input("what make is your " + str(device)).upper() 
    model = input("whats model is your " + str(device)).upper() 
    verison = input("what verison is your " + str(device)).upper() 
    memory = int(input("How much memory is in your " + str(device))) 
    print(make, model, verison, memory,"GB") 
    print(casenumber) 
    f = open('technician.txt','a') 
    f.write("**CASE NUMBER:{}** ** DEVICE: {}** **MAKE OF DEVICE: {}** **MODEL OF DEVICE: {} **".format(casenumber,device,make,model,verison,memory)) 
f.write("/n") 
f.close() 

我想要做的是在程序每次完成時在單獨一行中寫入。但/ n不起作用。我跑的程序兩次,它是所有在文本文件中的同一行寫:在文本文件的單獨行中寫入

病例號574927542749031461928599801595193290973875978 ** DEVICE:TABEL ** MAKE的設備:APPLE型號的設備:IPAD **/N案件編號:207884437699822095837989343019189844675528960 ** ** DEVICE:TABLET ** MAKE的設備:APPLE **模型設備:2 **/N

所有這一切都在同一行上。請幫助

非常感謝,

羅裏·伊斯特漢

+2

換行符是「\ n」而不是「/ n」。請注意反斜槓。 –

+0

感謝您的幫助:) –

回答

0

換行符是\n,而不是在你的程序中使用的/n。用這個更新你的代碼應該可以解決你描述的問題。

相關問題