Python-计算文本文件中的项目列表

时间:2017-03-07 10:15:56

标签: python

我是Python新手。我正在努力编写代码以获取项目列表的计数

keywords = ['bed', 'slot', 'display pane', 'graph', 'bedsides', 'multiviewer display', 'bed1'] 

在包含以下示例文本的文本文件中。

 Verify that the Respiration waveform size can be modified.                             
 Verify that changed Respiration waveform size is updated in Central Station.                               
 Verify that the Respiration Lead Selection settings are displayed as read-only for the Telemetry Bed at the Central Station.                               
 Verify that the NBP Auto mode settings are displayed for the Telemetry Bed at the Central Station.                                 
 Verify that the NBP cuff size settings are displayed as read-only for the Telemetry Bed at the Central Station.                                
 Verify that the ECG lead analysis options displayed for the Telemetry Bed at the Central Station include the following:                                
 Verify that the adjustment of the ECG Lead Analysis setting from Single-Lead and Multi-Lead is permitted for the Telemetry Bed at the Central Station.                                 
 Verify that the ECG Detect Pace settings displayed for the Telemetry Bed at the Central Station include the following:                             
 Verify that the adjustment of the ECG Detect Pace setting from PACE1    PACE2 and OFF is permitted for the Telemetry Bed at the Central Station.                           
 Verify that the ECG Display Lead settings displayed for the Telemetry Bed at the Central Station include the following:                                
 Verify that the adjustment of ECG Display Lead setting from I   II  III     V   aVR     aVL and aVF for the Telemetry Bed is permitted at the Central Station.             
 Verify that the SpO2 Waveform Size settings are displayed for the Telemetry Bed but it's read-only(grayed out).                                
 Verify that the Central Station shall display the NIBP auto mode setting as read only.                             
 Verify that the displayed NBP Stat mode settings are read-only for the Telemetry Bed at the Central Station.                               
 Verify that a means to clear the NBP message is provided for the Telemetry Bed at the Central Station.                             
 Verify that the message displayed for the Telemetry Bed in the Multiviewer  slot is cleared.                               
 Verify that the ECG Va Lead Selections displayed for the Telemetry Bed at the Central Station include the following:                               
 Verify that the adjustment of the ECG Va Lead Selection setting from V1     V2  V3  V4  V5 and V6 is permitted for the Telemetry Bed at the Central Station except for one of the Va lead which will be greyed out based on the Vb lead selected.              
 Verify that the ECG Vb Lead Selections displayed for the Telemetry Bed at the Central Station include the following:                               
 Verify that the adjustment of the ECG Vb Lead Selection setting from V2     V3  V4  V5 and V6 is permitted for the Telemetry Bed at the Central Station except for one of the Vb lead which will be greyed out based on the Va lead selected.                  
 Verify that the NBP Stat Mode setting is displayed as a read-only value of either ON or OFF for the Telemetry Bed at the Central Station.                              
 Verify that the message displayed for the Telemetry Bed in the Multiviewer  slot is cleared.                               
 Verify that the adjustment of the SPO2 rate setting is permitted for the Telemetry Bed at the Central Station.                             

注意:在查找列表项的计数之前,我还想将上面的文本转换为小写。

1 个答案:

答案 0 :(得分:0)

您应该查看re.findallhttps://docs.python.org/3.6/library/re.html#re.findall

使用re您可以忽略大小写,因此您不需要在以下情况下小写所有文字:)