mdk里面哪里看到本项目代码有多少行?
如题,不知道哪里查。MDK好像没有这个功能,不过支持这个功能的软件很多。 可以写一个 python 脚本来用
import os
def count_lines_in_file(file_path):
try:
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
return len(lines)
except Exception as e:
print(f"Error reading {file_path}: {str(e)}")
return 0
def count_c_code_lines_in_directory(directory_path):
total_lines = 0
for root, _, files in os.walk(directory_path):
for file in files:
if file.endswith(".c") or file.endswith(".h"):
file_path = os.path.join(root, file)
lines_count = count_lines_in_file(file_path)
total_lines += lines_count
return total_lines
if __name__ == "__main__":
folder_path = input("请输入要查找的文件夹路径: ")
total_lines = count_c_code_lines_in_directory(folder_path)
print(f"文件夹中的C代码总行数: {total_lines}")
tianmaduxing010 发表于 2023-9-6 00:11
可以写一个 python 脚本来用
import os
这个是否可以同时检测多个文件编码的文件的?很多时候UTF-8gb2312共存在一个目录下 git可以统计代码多少行 wdliming 发表于 2023-9-6 11:04
这个是否可以同时检测多个文件编码的文件的?很多时候UTF-8gb2312共存在一个目录下
用 Python 应该都可以实现 本帖最后由 caicaptain2 于 2023-10-8 13:28 编辑
tianmaduxing010 发表于 2023-9-6 00:11
可以写一个 python 脚本来用
import os
大侠在吗? 提示这个错误,似乎不认识utf8的文本?
Error reading C:\D\worklocal\code\testCubeF413\testcubef413\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h: 'utf-8' codec can't decode byte 0x92 in position 586: invalid start byte
另外,这个python的代码计算了全部库文件的代码行数,不管项目有没有使用,有没有参与编译,结果一个小小的项目是几十万行的代码。。。。
我用的这个软件
WangYI741 发表于 2023-10-8 13:56
我用的这个软件
这软件看着不错。 WangYI741 发表于 2023-10-8 13:56
我用的这个软件
这个是免费公益软件吗? 哪里有下载的 新开源项目:Count Tokens of Code
caicaptain2 发表于 2023-10-8 16:53
这个是免费公益软件吗? 哪里有下载的
1、SourceCounter:
2、代码统计:
3、代码行数统计
4、软件著作权源代码自动整理
WangYI741 发表于 2023-10-10 11:05
1、SourceCounter:
{:8:} 感谢分享,非常实用
页:
[1]