Why is p value different in same hypothesis? 
wilcox.test(weight ~ group, data = my_data, paired = TRUE)

wilcox.test(weight , group, data = my_data, paired = TRUE)


can anyone specify the difference to me with "," and "~" both are giving different outputs, whereas i use ggplot to see the data second one gives me the correct result that there is a difference in groups.
 A: These are totally different commands. In the first one, the syntax tells the function to stratify the weight according to the group and compare the weights of your groups. I suspect that you want this. In the second one, the syntax tells the function to compare the weights to the group labels, which I suspect are coded as $0$ and $1$. Depending on what you're weighing, I would expect all of the weights to be much higher than $1$. Consequently, the distributions of weights and 0/1 group labels are totally different, and the test catches this.
EDT
You're doing a paired test, so to be a bit more detailed, the first syntax tells the function to do a test on something like weight[group == 1] - weight[group == 0], while the second tells the function to do a test on weight - group.
A: If you are using a console like rstudio then you can use the command ?wilcox.test to get the manual of the function.

if both x and y are given and paired is TRUE, a Wilcoxon signed rank test of the null that the distribution ... of x - y (in the paired two sample case) is symmetric about mu is performed

That's probably not what you want, compare the variable weight and group. The formula form seems better, although it won't know how to pair the weights. It would be more ideal to construct two vectors manually.
