f=open(r'E:\我的文件\判断题.txt')
fnew=open(r'E:\我的文件\判断题-json.txt','a')
sum=0
str0=''
f1=f.readlines()
print(f1)
for f0 in f1:
sum=sum+1
print(sum)
for i in range(0,sum):
th=str(int(i+1))+'、'
print(th)
if(f1[i].find("( √ )")!=-1):
str0='{"name":"'+f1[i].replace("( √ )","")+'","daan":"√"},'
elif(f1[i].find("( x )")!=-1):
str0='{"name":"' + f1[i].replace("( x )", "") + '","daan":"x",'
else:
print("发生错误")
str0 = str0.replace('\n', '').replace(th, '') + '\n'
print(str0)
fnew.write(str0)
fnew.close()
f.close()
转前的.txt文件:
转后的json格式文件: