【发布时间】:2018-07-10 11:32:03
【问题描述】:
是否有命令获取列表项的总数?
例子:
Names = [['Mark'], ['John', 'Mary'], ['Cindy', 'Tom'], ['Ben']]
print (len(Names))
输出
4
但我想要列表项的总数,所以结果是 6。我刚开始学习 python,所以放轻松。
【问题讨论】:
-
欢迎来到 stackoverflow.com。请花点时间阅读the help pages,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。也请take the tour 和read about how to ask good questions。最后请学习如何创建Minimal, Complete, and Verifiable Example。
-
另外,请阅读this question checklist 和idownvotedbecau.se 的所有内容,了解您的问题可能被否决的一些原因。最后请learn how to debug your programs.