I have several stream segments 1000 Km long. I need to find the elevation difference between two consecutive points of distance 1 Km starting from the upstream to downstream. How can I get the elevation difference from DEM. I have stream segments in raster format and also in vector format. Hoping for your kind suggestion. It would be better if i got some idea on python script.

As it is a DEM, you get the elevation value under the point. With 3 raster bands with the same xy point you get 3 values (R,G,B). So you could make a function that allows to get the values of multiple rasters under a xy point:

# creation of an empty ogr linestring to handle all possible segments of a line with Union (combining the segements)
profilogr = ogr.Geometry(ogr.wkbLineString)
# open the profile shapefile
source = ogr.Open('profilline.shp')
cshp = source.GetLayer()
# union the segments of the line
for element in cshp:
geom =element.GetGeometryRef()
profilogr = profilogr.Union(geom)

To generate equidistant points on the line, you can use the Shapely module with interpolate (easier than ogr)

from shapely.wkb import loads
# transformation in Shapely geometry
profilshp = loads(profilogr.ExportToWkb())
# creation the equidistant points on the line with a step of 20m
lenght=profilshp.length
x = []
y = []
z = []
# distance of the topographic profile
dista = []
for currentdistance in range(0,lenght,20):
# creation of the point on the line
point = profilshp.interpolate(currentdistance)
xp,yp=point.x, point.y
x.append(xp)
y.append(yp)
# extraction of the elevation value from the MNT
z.append(Val_raster(xp,yp,layer, bands,gt)[0]
dista.append(currentdistance)

and the results (with also the RGB values of a geologic map) with the x,y,z, distance values of the lists
In 3D with matplotlib and Visvis (x,y,z values)