How to set edge bevel weights from a python script
There is no custom data layer for edge bevel weights by default. You need to explicitly enable it (this is done automatically if you use the Edge Bevel Weight modal operator in the UI):

ob = bpy.context.object
me = ob.data
me.use_customdata_edge_bevel = True


Furthermore, the mesh needs to be in Object Mode when you apply a bevel weight:

if ob.is_editmode:
    bpy.ops.object.mode_set(mode='OBJECT')
me.edges[0].bevel_weight = 0.7


If you want to avoid mode switching, you may use the bmesh module instead (bm.edges.layers.bevel_weight).