I agree with some PP it is much more important to be vigilant. I use to have to walk through Manchester city centre at night / early hours .
My tips , Be aware of your surroundings , know where the dark areas are , which roads are better lit .
Walk facing the oncoming traffic , it is much easier to flag a car down that is approaching you than past you , even if it doesn't stop it would put off your would be attacker . ( obs dont get into a strangers car ! )
If you are going to carry a spray of some sort it is no use in your bag , the Excuse me while I route around in my hand/ shopping bag for a weapon wont wash . keep it in your hand .
I did and still do use head phones but only in one ear and never loud , this has the advantage of if you see someone coming you start talking in a confident ( but not 'look at me' ) voice , ^oh I am just on xx road near x shop , so I will be home / you should be able to see me coming round the corner soon/ at work in a min or what ever fits the situation best .
Tell people where you are going and how long it will take you to get there .
Dont have your phone out and lit up like a light house , but do make sure it is fully charged , has credit , and the volume is off or very very low and discreet
Walk with confidence , even steady strides , don't walk so fast that you are short of breath but don't dawdle either .
If you think you are been followed , go into a shop , cross the road , walk up someones garden path, if possible hop on a bus
Even stop and start pacing up and down looking very cross , saying where the hell is he /she / they . they should be hear by now .