当前位置:
首页 >
python中doc=parased.getroot()_python中执行sed命令操作源文件时出现错误
发布时间:2025/3/11
38
豆豆
生活随笔
收集整理的这篇文章主要介绍了
python中doc=parased.getroot()_python中执行sed命令操作源文件时出现错误
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
我想在python中执行一个sed命令,第一种方法直接指定文件时,可以正确输出结果,但是第二种我打开文件操作的时候就有问题,不知道什么原因,求高手解答?
(1)
>>> sedcmd="sed -n \'s/{//g; p\' /qye/python/mytestpython/tmp.txt"
>>> a=os.popen(sedcmd)
>>> a.readlines()
["'copy_reg': , 'encodings': , 'site': , '__builtin__...module 'exceptions'(built-in)>, 'abrt_exception_handler': , 'os':}\n", '\n']
>>>
(2)
>>> withopen("/qye/python/mytestpython/tmp.txt") as srcfile:
... sedcmd="sed -n \'s/{//g;p\' srcfile"
... a=os.popen(sedcmd)
...
>>> sed: can't read srcfile: No such file ordirectory
总结
以上是生活随笔为你收集整理的python中doc=parased.getroot()_python中执行sed命令操作源文件时出现错误的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: impala和mysql语法,impal
- 下一篇: python—高阶函数