如何从python文件中读取下一行或下一行的单词?(How to read next word or words till next line from file in python?)
我想在匹配单词后从一行读取单词:
确切地说 - 我有一个文件如下:
-- Host: localhost -- Generation Time: Nov 15, 2006 at 09:58 AM -- Server version: 5.0.21 -- PHP Version: 5.1.2
我想搜索一下,如果该文件包含'服务器版本:'子字符串,如果然后读取'服务器版本:'之后的下一个字符直到下一行,在这种情况下为'5.0.21'。
我尝试了以下代码,但它给出了下一行( - PHP版本:5.1.2)而不是下一个单词(5.0.21)。
with open('/root/Desktop/test.txt', 'r+') as f: for line in f: if 'Server version:' in line: print f.next()
i'm trying to read words from a line after matching words :
To be exact - I have a file with below texts:
-- Host: localhost -- Generation Time: Nov 15, 2006 at 09:58 AM -- Server version: 5.0.21 -- PHP Version: 5.1.2
I want to search that, if that file contains 'Server version:' sub string, if do then read next characters after 'Server version:' till next line, in this case '5.0.21'.
I tried the following code, but it gives the next line(-- PHP Version: 5.1.2) instead of next word (5.0.21).
with open('/root/Desktop/test.txt', 'r+') as f: for line in f: if 'Server version:' in line: print f.next()
原文:https://stackoverflow.com/questions/24753866
最满意答案
在映射之前,只需使用选择器在两个表中选中复选框:
var boxes = $('input:checkbox:checked', '#MainContent_CBLFYSubjects, #MainContent_CBLSYSubjects'), subjes = $.map(boxes, function(el){ return el.value; });
Just use a selector that selects checkboxes in both tables before you map them :
var boxes = $('input:checkbox:checked', '#MainContent_CBLFYSubjects, #MainContent_CBLSYSubjects'), subjes = $.map(boxes, function(el){ return el.value; });
相关问答
更多-
jquery mobile 页面跳转第二次不刷新怎么办[2022-09-17]
checkbox -
jquery mobile本地和环境中显示问题[2023-06-25]
checkbox -
jquery mobile 点击跳转不加载数据怎么回事[2023-11-26]
checkbox -
jQuery Mobile框架弹窗中放表单文本框,整个弹窗区域都会变为文本框的触发焦点,不想这样[2022-03-02]
checkbox -
如何在 jQuery Mobile 的 Listview 中动态移除某一条的图标[2023-09-01]
checkbox -
// jQuery wrapper (function($){ // document-ready wrapper $(function(){ var arrMonth = [ "November", "October", "December"]; //Loop through the array and check each element against the check box list //if found, make the ...
-
你的意思是这样的吗? var arrCheckboxes; var checkboxSelector = "input[type='checkbox']"; $("body").delegate(checkboxSelector , "click", function(){ arrCheckboxes = $(checkboxSelector).map(function() { return this.checked; }).get(); }); (也许你应该将$(“bod ...
-
用这个 $IDs = $("#table input:checkbox:checked").map(function () { return $(this).attr("id"); }).get(); use this $IDs = $("#table input:checkbox:checked").map(function () { return $(this).attr("id"); }).get();
-
如何使用jquery从两个表检查复选框值获取?(how to get from two table checked checkbox values using jquery?)[2023-06-16]
在映射之前,只需使用选择器在两个表中选中复选框: var boxes = $('input:checkbox:checked', '#MainContent_CBLFYSubjects, #MainContent_CBLSYSubjects'), subjes = $.map(boxes, function(el){ return el.value; }); Just use a selector that selects checkboxes in both table ... -
使用jquery插件从treeview复选框中获取选中的值(Getting checked values from treeview checkbox using jquery plugin)[2021-07-02]
这是为父母mockData [0] .item.checked这是为孩子mockData [0] .children [0] .item.checked this is for parent mockData[0].item.checked this is for children mockData[0].children[0].item.checked