我正在尝试使用 namedtuple 将 Python 对象序列化为 JSON。但我得到这个错误。谷歌没有帮助。
Traceback (most recent call last):
File "cpu2.py", line 28, in <module>
cpuInfo = collections.namedtuple('cpuStats',('cpu.usr', ('str(currentTime) + " "
+str(cpuStats[0]) + " host="+ thisClient')), ('cpu.nice', ('str(currentTime) + " "
+str(cpuStats[1]) + " host="+ thisClient')), ('cpu.sys',('str(currentTime) + " "
+str(cpuStats[2]) + " host="+ thisClient')), ('cpu.idle',('str(currentTime) + " "
+str(cpuStats[3]) + " host="+ thisClient')))
TypeError: namedtuple() takes at most 4 arguments (5 given)