2

如何计算在 python 项目中包含多个子目录的项目中写入的行数。例如 dir 结构就像

A  
 \ <*some files here*>\  
  B  
   \ <*some files here*>\ ... and so on...
4

1 回答 1

12

您可以在 linux 中使用 find 实用程序。

在命令提示符下:

$ find <project_directory_path> -name '*.py' | xargs wc -l

这将为您提供 project_directory 中所有以 .py 结尾的文件的计数,最后是总数。(我假设您只想要 .py 文件的数量)

如果您只想要总数而不需要其他任何东西,您可以使用:

$ find <project_directory_path> -name '*.py' | xargs wc -l | tail -1
于 2011-09-29T00:52:43.887 回答