import bpy

# オブジェクト内の三角形をカウント
# 三角形でないものはカウントしない
def count_triangle(obj):
    
    mesh = obj.data
    tri_count = 0
    for poly in mesh.polygons:
        if len(poly.vertices) == 3:
            tri_count += 1

    return tri_count

# 呼び出し例
print (count_triangle( bpy.context.active_object ) )

 

 

import bpy

# メッシュ内の三角形をカウントする
# 三角形でないものは三角形に分割されたものとしてカウントされる
def count_triangle_loop(obj):
    mesh = obj.data
    mesh.calc_loop_triangles()
    
    tri_count = 0
    
    for tri in mesh.loop_triangles:
        tri_count += 1
        
    return tri_count


# 呼び出し例
print (count_triangle_loop( bpy.context.active_object ) )