I have a list that looks like this:
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', '}']
Why does this:
for line in jvmLines:
if "name=" in line:
print line
Lead to this?
TypeError: string member test needs char left operand
I also get the same if I try lambda functions or a filter()
try the find()
method
for line in jvmLines:
if line.find('name=') >= 0:
print line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With