s=[2,0,2,0,0,5,2,3] str1="" for a in s: if a>0: #条件 str1=str1+"@" elif a==0:#条件 str1=str1+"&" print(str1) 运行结果: