zoukankan      html  css  js  c++  java
  • tongjiword,write / read file demo

    1.tong ji letter demo

    mport sys

    def tongjiword():
    fi =open(paht,'r')
    cont=fi.read()
    wl={}
    for line in fi.read():
    lin =line.trip()
    for i in range(len(lin)):
    if lin(i) not in wl:
    wl[lin(i)] =0
    wl[line(i)] +=1

    temp = sorted(wl.items,key=lambda:d:d(1),reverse=True)
    print(temp)

    f=open(path,'w',encoding='utf-8')
    for item in temp:
    str=item[0]","+ str(item[1])
    f.write(str+" ")
    f.colse()

    2. write read file demo

    import sys


    def reafile(path):
    fi=open(path,"r")
    #fi=open(path,"rb")
    try:
    text=fi.read()
    #text=fi.read(100)
    #text=fi.readlines()
    finally:
    fi.colse()

    def writefile(path):
    fi=open(path,"w")
    #fi=open(path,'wb')
    #fi=open(path,'w+')
    try:
    fi.write("alltext")
    #fi.writelines("alltext")
    finally:
    fi.colse()

  • 相关阅读:
    1221D
    1249E
    D. Yet Another Monster Killing Problem
    大佬传送门
    Zookeeper客户端连接报错
    搭建PXC集群
    Docker分布式环境
    Docker使用
    Docker入门
    MySQL数据库集群概述
  • 原文地址:https://www.cnblogs.com/csj007523/p/7681691.html
Copyright © 2011-2022 走看看