python--file operater

#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Administrator'
#data=open("yesterday",encoding="utf-8").read()
#f=open("yesterday",encoding="utf-8")
#1. f=open("yesterday2","w",encoding="utf-8")

#append
#f=open("yesterday2","a",encoding="utf-8")
#f=open("yesterday","r",encoding="utf-8")

#f=open("yesterday","r+",encoding="utf-8")  #文件句柄    读写
#f=open("yesterday2","w+",encoding="utf-8")  #文件句柄    写读(X)
#f=open("yesterday2","a+",encoding="utf-8")  #文件句柄    追加读写

#f=open("yesterday2","rb")  #文件句柄  二进制文件
f=open("yesterday2","wb")  #文件句柄  二进制文件
f.write("hello binary!!!!".encode())
f.close()
#print(f.readline())
#data=f.read()
#data2=f.read()
#print(data)
#print("---------data2-------",data2)
#f.write("我爱北上广\n")
#f.write("北上广不相信泪水............")

#"a" is not read,but it can write
'''
f.write("when i was young,i listen to the radio\n")
data=f.read()
print(data)'''

#print(f.readlines())
'''for line in f.readlines():
    print(line.strip())'''
#low loop
'''for index,line in enumerate(f.readlines()):
    if index==9:
        print('----line------')
        continue
    print(line.strip())'''

#high bige
'''
count=0
for line in f:
    if count==9:
        print('----line------')
        count+=1
        continue
    print(line)
    count+=1'''

'''for i in range(5):
    print(f.readline())'''

'''
print(f.tell())
print(f.read(5))
#print(f.readline())
print(f.readline())
print(f.readline())
print(f.readline())
print(f.tell())
#回溯
f.seek(0)
print(f.readline())
print(f.encoding)
#print(f.fileno())
#print(f.seekable())
#print(f.readable())
print(f.flush())
print(dir(f.buffer))
'''
#从“头”开始截断
#f.truncate(9)
#print(f.readline())
'''
for i in range(3):
    print(f.readline())
f.write("-------插入数据---------")
f.write("-------插入数据---------")
print(f.tell())
f.seek(10)
print(f.readline())
f.write("second line")'''
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
-------------------------------------------- C++ Call Stacks (More useful to developers): -------------------------------------------- Windows not support stack backtrace yet. ------------------------------------------ Python Call Stacks (More useful to users): ------------------------------------------ File "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1843, in append_op attrs=kwargs.get("attrs", None)) File "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/layers/nn.py", line 9597, in relu6 attrs={'threshold': threshold}) File "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py", line 171, in conv_bn_layer return fluid.layers.relu6(bn) File "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py", line 198, in inverted_residual_unit name=name + '_expand') File "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py", line 252, in invresi_blocks name=name + '_' + str(i + 1)) File "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py", line 110, in net name='conv' + str(i)) File "test.py", line 107, in run emb = model.net(image) File "test.py", line 318, in main testor.run() File "test.py", line 323, in <module> main() ---------------------- Error Message Summary: ---------------------- Error: Fail to allocate CPU memory: size = 114987136 . [Hint: p should not be null.] at (E:\Paddle\paddle\fluid\memory\detail\system_allocator.cc:61) [operator < relu6 > error]
07-12
根据给出的Python调用栈信息,您遇到了一个内存分配错误。错误消息提示在 E:\Paddle\paddle\fluid\memory\detail\system_allocator.cc 的第 61 行出现了一个空指针错误。同时,调用栈显示了涉及的函数调用序列: 1. 在 "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/framework.py" 的第 1843 行,调用了 append_op 函数。 2. 在 "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/layer_helper.py" 的第 43 行,调用了 append_op 函数。 3. 在 "/data/yourenchun/share/projects/renzheng/liuyi/liuyi_env/Python-2.7.14/lib/python2.7/site-packages/paddle/fluid/layers/nn.py" 的第 9597 行,调用了 relu6 函数。 4. 在 "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py" 的第 171 行,调用了 conv_bn_layer 函数。 5. 在 "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py" 的第 198 行,调用了 inverted_residual_unit 函数。 6. 在 "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py" 的第 252 行,调用了 invresi_blocks 函数。 7. 在 "/data/yourenchun/share/projects/renzheng/slurm/dist_arcface/models/mnasnet.py" 的第 110 行,调用了 net 函数。 8. 在 "test.py" 的第 107 行,调用了 run 函数。 9. 在 "test.py" 的第 318 行,调用了 model.net(image)。 10. 在 "test.py" 的第 323 行,调用了 testor.run()。 11. 在 "test.py" 的第 323 行,调用了 main 函数。 根据错误消息和调用栈信息,问题可能出现在您的代码中的某个地方导致内存分配失败。您可以检查相关代码,确保内存分配和释放的正确性,并确保所需的内存不超过系统可用内存。此外,还可以考虑减小输入数据的规模或使用更高效的算法来降低内存需求。 如果您需要更详细的帮助,请提供更多关于代码和环境的信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值