4

次のようなリストがあります。

wsadmin>print jvmLines
['', 'Stats name=jvmRuntimeModule, type=jvmRuntimeModule#', '{', 'name=HeapSize, ID=1, description=The total memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=BoundedRangeStatistic, lowWaterMark=1048576, highWaterMark=1048576, current=1048576, integral=0.0, lowerBound=1048576, upperBound=2097152', '', 'name=FreeMemory, ID=2, description=The free memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=176789', '', 'name=UsedMemory, ID=3, description=The amount of used memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=871786', '', 'name=UpTime, ID=4, description=The amount of time (in seconds) that the Java virtual machine has been running., unit=SECOND, type=CountStatistic, count=3809648', '', 'name=ProcessCpuUsage, ID=5, description=The CPU Usage (in percent) of the Java virtual machine., unit=N/A, type=CountStatistic, count=1', '}']

なぜこれを行うのですか:

for line in jvmLines:
    if "name=" in line:
        print line

これにつながる?

TypeError: string member test needs char left operand

ラムダ関数または filter() を試しても同じ結果になります

4

2 に答える 2

9

find()メソッドを試す

for line in jvmLines:
    if line.find('name=') >= 0:
        print line
于 2013-10-03T14:55:46.283 に答える