Python:如何在多行字符串中搜索特定内容
创建了一个字符串
connectString = 'D:\Database\10.2.0\BIN\sqlplus.exe -L sys/PASSWORD'
output = str(call(connectstring))
打印输出的结果
stuff stuff stuff
stuff even more stuff
ORA-28009
stuff stuff
stuff and stuff
我已经根据
output.find('ORA-28009')
,但它找不到字符串序列。我能想到的唯一原因是字符串是多行的。我该如何处理这个问题?
I have created a string from
connectString = 'D:\Database\10.2.0\BIN\sqlplus.exe -L sys/PASSWORD'
output = str(call(connectstring))
this results from print output
stuff stuff stuff
stuff even more stuff
ORA-28009
stuff stuff
stuff and stuff
I do
output.find('ORA-28009')
but it does not find the string sequence. The only reason I can think of is because the string is multi line. How do I handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试规范化字符串,删除特殊字符。
我使用这样的函数:
也许你可以根据你的情况调整它。
最好的,
斯特
try to normalise the string removing the special charachter.
i use a function like this:
Maybe you can adapt it to your case.
best,
Ste
这就是我所做的来解决它。需要 sPath 变量,因为我在同一服务器上有两个单独的 Oracle 实例。为了正确测试 sys 帐户密码,我需要使用该实例的正确密码运行特定目录中包含的 sqlplus。
This is what I did to solve it. The sPath variable is needed because I have two seperate instances of Oracle on the same server. To properly test the sys account password I needed to run the sqlplus contained in the specific dir with the correct password for that instance.
尝试替换
为
which 返回命令输出中的字节。
Try replacing
with
which returns the bytes from the output of the command.