python文件小操作

def read():
    number=eval(input())
    return number
def gets():
    s=input()
    return s
def cout(x):
    print(x)
def main():
    f=open('mgw.txt','r',encoding='utf-8')
    while True:
        lom=f.readline()
        if not lom:
            break
        tom=lom.split()
          # if '张三' in tom[0]:
        for i in tom:
             print(i,end=' ')
        cout('\n')
    f.close()
    exit(0)
main()

python文件小操作_第1张图片
python文件小操作_第2张图片

def read():
    number=eval(input())
    return number
def gets():
    s=input()
    return s
def cout(x):
    print(x)
def main():
    f=open('mgw.txt','a+',encoding='utf-8')
    f.write(
        "I am Baweier\r\nthan i ...."
    )
    f.close()
    f=open('mgw.txt','r',encoding='utf-8')
    while True:
        lom=f.readline()
        if not lom:
            break
        tom=lom.split()
          # if '张三' in tom[0]:
        for i in tom:
             print(i,end=' ')
        cout('\n')
    f.close()
    exit(0)
main()

python文件小操作_第3张图片

你可能感兴趣的:(python)