python中doc=parased.getroot()_python中执行sed命令操作源文件时出现错误
生活随笔
收集整理的這篇文章主要介紹了
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
- 下一篇: php curl keepalive,H