鳟鱼小 发表于 2017-1-4 15:09:27

积极回复

5805461 发表于 2017-1-12 11:03:56

sadsadasdsadsadasd

真阿布 发表于 2017-1-17 00:47:46

>>> resultFile = open('e:\\temp\\OpenMe.txt','w')
>>> for each in f:
        resultFile.write(each)

鳟鱼小 发表于 2017-1-17 17:06:46

没有鱼币,蛋疼得

tttb 发表于 2017-1-19 11:42:41

感谢小甲鱼老师

liuganzhihui 发表于 2017-2-10 10:33:07

学习中 狗狗狗

liuganzhihui 发表于 2017-2-10 10:46:13

热爱鱼C

lanxury 发表于 2017-2-14 09:05:37

支持

ChirsJiD 发表于 2017-2-21 10:29:01

谢谢

hukaichunhu 发表于 2017-2-23 22:06:01

这个好

Muia 发表于 2017-2-24 21:52:16

。。。。。。。。。。。

Engou 发表于 2017-2-25 09:22:42

很有帮助

arbain 发表于 2017-3-9 10:53:54

哈哈哈哈

Eagle.Tong 发表于 2017-4-4 16:13:11

def find_eachline(str,character):
    lis = str.split(character)
    num = len(lis) - 1
    return num

def find_all(file,character):
    f = open(file)
    flag = 0
    for eachline in f:
      n = find_eachline(eachline,character)
      flag += n
    f.close()
    return flag

def all_replace(file,old,new):
    n = find_all(file,old)
    f = open(file)
    print("There are %d %s"%(n,old))
    choice = input("Are you sure to replace %s with %s 【Y/N】?"%(old,new))
    temp = []
    if choice == 'Y':
      for eachline in f:
                temp.append(eachline.replace(old,new))
    f.close()
    f = open(file,'w')
    f.writelines(temp)
    f.close()


      




file = input("Please enter filename: ")
old = input("Please enter the characters will be replaced: ")
new = input("Please enter the new character: ")

all_replace(file,old,new)

thewq 发表于 2017-4-12 22:04:52

谢谢小甲鱼老师分享

786857040 发表于 2017-4-23 22:40:44

f.truncate()怎么用?

dubian 发表于 2017-4-27 23:12:15

111

Python_meng 发表于 2017-5-3 15:36:50

支持甲鱼老师!

z62521708 发表于 2017-5-7 16:31:42

0.将列表 字典 集合等转为二进制存储 然后再调用?
1.pickle.dump()
2.pickle.load()
3.可以

0.   # 遇到多个等号来分割应该怎么搞
   #
def hanshu():
    import pickle
    count=1
    boy_count=[]
    girl_count=[]
    f=open(C:\Users\pokemon\Desktop\record.txt,'wb')
    for each in f:
      (person,content) =each.split(:)#正确的分割形式是怎样的?...
      if person == 小甲鱼:
            boy_count.append(content)
      if person == 小客服:
            girl_count.append(content)
      count+=1
      f1=open(D://下载//boy_count.txt.'w+')
      f2=open(D://下载//girl_count.txt.'w+')
    if each ==
   

wyh2006 发表于 2017-5-15 14:25:35

谢谢版主分享!!!
页: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14
查看完整版本: 文件的打开模式和文件对象方法