我是编写 Python 脚本的初学者,我需要以下方面的帮助:
线程::num,47141,47146,47151,47156,47161,47166,47171,47176
如何获取并显示最后一个值“47176”?
以下是我编写的部分代码:
elif sys.argv[1] == "-c":
b = sys.argv[2]
with open(b) as f:
for line in f:
if 'Threads::num' in line:
print line.strip(',').split(',')[-1]
print line
此代码的输出是它显示所有值,如下所示:
Threads::num,47141,47146,47151,47156,47161,47166,47171,47176
-sid