#coding:utf8
def isalary():
# 若写入文件时,要追加到同一个文件,则open(u"information.txt","a")
with open(u"F:/file1.txt","r") as fp,open(u"information.txt","w") as fi:
#获取文件的内容 可以直接f=fp.readlines不用下一步
f = fp.read()
#将读取的数据分割放在列表里
f =f.splitlines()
for one in f: #先将每一行去空格
one = one.strip()
#如果是空行,跳过本次循环
if one == "":
continue
if one.count(";") != 1:
continue
#将字符串分割,获取字段
namepart,salarypart = one.split(";")
salary = int(salarypart.split(":")[1].strip())
name = namepart.split(":")[1].strip()
tax = int(salary*0.1)
incom = int(salary*0.9)
#coding:utf8def isalary(): # 若写入文件时,要追加到同一个文件,则open(u"information.txt","a") with open(u"F:/file1.txt","r") as fp,open(u"information.txt","w") as fi: #获取文件的内容 可以直接f=fp.rea