I love London but I think it's a city best enjoyed when you have a job and money.
Finding accommodation there is the biggest pain in the world. And it stems from not having enough money no matter how far you stretch it. You end up having to live in a grotty house miles away and that impacts on the cost of transportation and time it takes to get into lectures. And that may well eat into whatever you have left to have fun in a very expensive city. And the crowds really wear you out - on the street, in the tube, the buses. The tourists are dreadfully slow and I cycle in personally.
On the plus side, you do have amazing resources at your fingertips including the libraries, museums, visiting lecturers. And you're at the centre of everything - there isn't a weekend when there isn't a protest march outside Parliament or a festival in Traf Sq.
Having lived there for 3 years I don't think it's any less safe than other places. Certainly in the West End there are so many people it's not a problem. You just have to be streetsmart, more careful outside zone 1 at night when you're on you're own, but that goes for anywhere in the world. I wouldn't make it too much of a factor in your decision.
I'd personally pick St Andrews - there's plenty of time to enjoy London later.