(Scripting) Import & assign material from another blend file
data_from are just string lists, in this case, the names of materials in the Blend file designated by the path. data_to is a string list of the names of the materials you want to be loaded. So, whatever names you put in data_to.materials will be loaded from the designated Blend file's material data block into the current material data block. After that, you access those materials in the material data block, i.e., bpy.data.materials. So, your code should read:

with bpy.data.libraries.load(path) as (data_from, data_to):

    data_to.materials = data_from.materials
    mat = data_to.materials
    cnt=0
    for m in data_to.materials:
        cnt=cnt+1
        if (cnt&gt;1): 
            break  
        # Assign material
        obj=bpy.context.scene.objects.active
        material1 = bpy.data.materials[mat[cnt]]
        obj.active_material = material1


Note that this could give unexpected results if a material name already exists in the material data block.