博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Date3
阅读量:6932 次
发布时间:2019-06-27

本文共 1595 字,大约阅读时间需要 5 分钟。

进度条:
#Author:Brillimport sys,timefor i in range(50):    sys.stdout.write("#")    sys.stdout.flush()    time.sleep(0.1)
View Code
文件修改:(未成功)
#Author:Brillf = open("yesterday2","r",encoding="utf-8")f_new = open("文件名","w",encoding="utf-8")for line in f :    if "要改的内容" in line:        line = line.replace("要改的内容","新的内容")    f_new.write(line)f.close()f_new.close()
View Code
 文件相关操作:
#Author:Brill#data  = open("yesterday",encoding="utf-8").read()f  = open("yesterday2",'a',encoding="utf-8")f.write("When I was young I listen to the radio.\n")data = f.read()print("-----read----",data)f.close()f  = open("yesterday2",'r',encoding="utf-8")for index,line in enumerate(f.readlines()):    print(line.strip())    if index == 9:        print("-------------I am middle-------------")        continue    print(line.strip())#for i in range(5): #   print(f.readline())f  = open("yesterday2",'r',encoding="utf-8")count = 0for line in f :    if count == 9:        print("------------------I am you----------------")        count +=1        continue    print(line)    count +=1f  = open("yesterday2",'r',encoding="utf-8")print(f.tell())print(f.readline())print(f.readline())print(f.readline())print(f.tell())f.seek(10)print(f.readline())print(f.encoding)print(f.fileno())print(f.flush())print(f.buffer)print(dir(f))f.close()f = open("yesterday2","a",encoding="utf-8")f.seek(10)f.truncate(10)f = open("yesterday2","r+",encoding="utf-8")print(f.readline())print(f.readline())print(f.readline())f.write("------------Hello--------------------")print(f)
View Code
 
 
 

转载于:https://www.cnblogs.com/genghenggao/p/9028971.html

你可能感兴趣的文章
从零开始搭建ELK+GPE监控预警系统
查看>>
SQL Server 2008性能故障排查(二)——CPU
查看>>
[20170825]2038.txt
查看>>
TCP的三次握手和四次挥手(转)
查看>>
【数据蒋堂】第33期:JOIN提速 - 外键指针化
查看>>
你“同意”过最可怕的互联网霸王条款是?
查看>>
APPcrawler基础原理解析及使用
查看>>
Kafka监控架构设计
查看>>
自定义View系列教程04--Draw源码分析及其实践
查看>>
【PHP】Window7环境下配置PHP7+Apache2.4 环境
查看>>
开发中遇到的编码问题(转)
查看>>
ICCV2017 论文解读:基于图像检索的行人重识别 | PaperDaily #13
查看>>
关于指针
查看>>
PHP XML和数组互相转换
查看>>
Hbase操作table常见方法示例
查看>>
Flink批处理中的增量迭代
查看>>
Mac OS X各版本的历史费用和升级关系
查看>>
SharePoint 2016 配置向导报错 - The 'ListInternal' attribute is not allowed
查看>>
js String Trim函数
查看>>
MFC使用自定义资源加载PNG
查看>>