خرید بک لینک

Vote count: 0

So I am writing this code

spec = raw_input("Enter the specimen number: ")
naorimp = raw_input("Native or Implant (N/I)? ")
trial = raw_input("Trial number: ")
typana = raw_input("What do you want to analyze (contact area[CA]/contact pressure[CP])? ")

try :
    if typana.lower() == "cp" :
        naorimp = naorimp.upper()
        TSfilnm = 'pressure'+spec+naorimp.upper()+trial+'.txt'
    else :
        naorimp = naorimp.upper()
        TSfilnm = 'area'+spec+naorimp+trial+'.txt'
    TSfile = open(TSfilnm, 'r')
    myofilnm = 'accelerometer'+spec+naorim.upper()+trial+'.txt'
    print myofilnm
    myofile = open(myofilnm, 'r')
except :
    print "File could not be found."
    print "Please re-run the program."
    exit()

print "OK"

I want to open a file based on user's input on several parameters (specimen no., native or implant, trial no., and type of analysis.) The file is already in the same folder as the python file code. But when I run the program I always end up with except statements (File could not be found. Please re-run the program). I have double-checked the real file name and the string inside the TSfilnm variable, and they are the same. However, the TSfile could not be executed.

P.S. The file name in my folder is: pressure3N1.txt, area3N1.txt, accelerometer3N1.txt

asked 1 hour ago
aold

- - , .

برچسب: نویسنده: استخدام کار تاريخ: جمعه 7 اسفند 1394 ساعت: 12:04

صفحه بندی