When I paint in vertex paint mode, can I paint per vertex with python script?
This does what you want I think. It's not particularly efficient though since it loops through all verts and all loops.
import bpy

ob = bpy.context.active_object
assert ob.type == 'MESH'
assert ob.mode == 'VERTEX_PAINT'

mesh = ob.data

# Get the active vertex color layer
color_data = mesh.vertex_colors.active.data

# Find index of all selected verts
sel_vindexs = set(
    v.index for v in mesh.vertices if v.select
)

# Find all loops (loop = corner of a poly) that touch
# a selected vert and make them to red
for loop in mesh.loops:
    if loop.vertex_index in sel_vindexs:
        color_data[loop.index].color = [1, 0, 0, 1]