python实现excel表格读写 *** 作

python实现excel表格读写 *** 作,第1张

python实现excel表格读写 *** 作
import xlrd
import re
def filetest1():
    with open('file/akko') as file_object:
        # with open('D:test/test.txt') as file_object:
        # 绝对路径
        # print(type(file_object.read().rstrip()))  #read到文件末尾时会返回一个空字符串 这个空字符串打印出来显示空行
        obj1 = file_object.read().rsplit()  # 空格切片
        for i in obj1:
            print(i)
        # print(file_object.read().rstrip())  #不显示空行
def filetest2():
    with open('file/akko') as file_object:
        str = ''
        obj2 = file_object.readlines();
        for line in obj2:
            print(line)
            str+=line.rstrip()
        print(str)
def wirtefile1():
    filenamme='file/akko1.txt'
    with open(filenamme,'w') as file_obj:
        file_obj.write("test1ntest2ntest3")
def writefile2():
    filenamme = 'file/akko1.txt'
    with open(filenamme, 'a') as file_obj:
        file_obj.write("测试附加1n测试附加2")
def exceltes

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4830294.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-10
下一篇 2022-11-10

发表评论

登录后才能评论

评论列表(0条)

保存