示例數(shù)據(jù):
湘西土家族ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!zs,3
li,5
ww,10
cc,4
xm,2
xh,1
pp,6
qq,7
ff,11
dd,8
kk,12
mm,9
處理后效果:
腳本代碼如下:
創(chuàng)建 文件名.py 腳本文件
fo = open("/home/python/hhh/a.txt", "r") print ("文件名為: ", fo.name) a=[] for line in fo: a.append(line) f01 = open("/home/python/hhh/b.txt", "a") for index in range(len(a)): b=a[index].split(',') test=b[0] a1=b[1] if a1 == '1\n': f01.write(test+",Jan\n") if a1 == '2\n': f01.write(test+",Feb\n") if a1 == '3\n': f01.write(test+",Mar\n") if a1 == '4\n': f01.write(test+",Apr\n") if a1 == '5\n': f01.write(test+",May\n") if a1 == '6\n': f01.write(test+",Jun\n") if a1 == '7\n': f01.write(test+",Jul\n") if a1 == '8\n': f01.write(test+",Aug\n") if a1 == '9\n': f01.write(test+",Sep\n") if a1 == '10\n': f01.write(test+",Oct\n") if a1 == '11\n': f01.write(test+",Nov\n") if a1 == '12\n': f01.write(test+",Dec\n")