Python:用sys.stdin和sys.stdout从文件中读写数据

#!/usr/bin/env python
# coding:UTF-8


"""
@version: python3.x
@author:曹新健
@contact: [email protected]
@software: PyCharm
@file: 0925ex.py
@time: 2018/9/25 22:37
"""

import  sys

#数据区start
zhangSan = {"name":"张三","age":18,"pay":200,"job":"学生"}
liSi = {"name":"李四","age":28,"pay":20000,"job":"程序员"}
LeeMin = {"name":"LeeMin","age":26,"pay":30000,"job":"销售"}

person = {}
person["zhangSan"] = zhangSan
person["liSi"] = liSi
person["LeeMin"] = LeeMin
#数据区end

#标志区
fileName = "people-file"
ENDDB = "enddb."
ENDREC = "endrec."
RECSEP = "=>"

#代码区
def storeDbase(db,file):
    with open(file,"w") as dbFile:
        sys.stdout = dbFile
        for key in db:
            print(key)
   

你可能感兴趣的:(Python基础知识,Python基础知识)