В основном вы получаете:
try:
1/0
except ZeroDivisionError:
print('OOPS')
OOPS
Так почему бы и нет:
try:
prop=str(float(XX[1])*float(XX[4])*float(XX[5])*temp/float(XX[7]))
except ZeroDivisionError:
pass
# Or prop = 0
# Or some other action
UPDATE . Я не могу воспроизвести синтаксическую ошибку:
try:
prop=str(float(4)*float(3)*float(2)*5/float(0))
except ZeroDivisionError:
prop = 0
# test
prop
0
Дальнейшее ОБНОВЛЕНИЕ
for x in qty:
aa=x.split()
if float(aa[1])==temp:
first=str(float(aa[0])*ry_ev-ef)
car_cm=str((float(aa[2])-cc_ef)/vol)
pff=str(float(aa[4])*float(aa[4])*float(aa[5]))
try:
ztt=str(float(aa[4])*float(aa[4])*float(aa[5])*temp/float(aa[7]))
except ZeroDivisionError:
ztt=0
finally:
seeb.write(first + "\t" + aa[4] + "\t" + car_cm + "\n")
elc.write(first + "\t" + aa[5] + "\t" + car_cm + "\n")
eth.write(first + "\t" + aa[7] + "\t" + car_cm + "\n")
pf.write(first + "\t" + pff + "\t" + car_cm + "\n")
zt.write(first + "\t" + ztt + "\n")
dos.write(first + "\t" + aa[3] + "\n" )
cc.write(first + "\t" + car_cm + "\n")
itr1+=1
Это дает:
Traceback (most recent call last):
File "all-graphs.py", line 44, in <module>
zt.write(first + "\t" + ztt + "\n")
TypeError: can only concatenate str (not "int") to str
Это проблема с приведением типов и вы решаете это с помощью ztt = "0"
в исключении или str(ztt)
в write ().