#!/usr/bin/python3
#coding:utf8
with open("/etc/passwd") as f:
result = {"system":0,"local":0}
for line in f:
args = line.split(":")
d = dict(
username = args[0],
passwd = args[1],
uid = args[2],
gid = args[3],
description = args[4],
homepath = args[5],
script = args[6]
)
uid = int(d["uid"])
if uid in range(500):
result["system"] += 1
elif uid >= 500:
result["local"] += 1
print(result)
执行结果: