I borrowed my friend's DSO to complete my project(Hantek DSO5072), but on scope it says CAT II/400V. So is it safe to measure 220Vrms@50Hz with it?
I see several "scary" elements in your question.
This isn't your DSO, you should use it only to measure "safe" (low voltage) things. When in doubt: only things that are battery powered.
CAT II/400V says something about what the oscilloscope can handle at its inputs. It doesn't tell you anything about your safety.
Also: Why would you need to measure mains voltage?
If that really is your goal, measure the output of a power adapter that outputs a low value AC voltage (so not DC) of 15 V AC for example. These are rare nowadays but were more common 20 years ago.
The issue is that the oscilloscope has inputs that are grounded on one side. Grounded meaning connected to Earth, assuming it is connected to the mains properly, so using a cable with Earth and using a proper Earthed socket. If you then would "measure the mains" there's a large chance that you will get a big spark when you connect the scope. And if you're lucky the Ground Fault detection (if that is present in your house and working) will switch off the mains power.
If you're unlucky you can connect the mains to the scope and then your scope could be mains live meaning you will get an electric shock when you touch it.
You should watch EEVBlog Dave Jones' video on this subject: How NOT To Blow Up Your Oscilloscope
After your added comment: you might need a high voltage probe specifically designed for these kinds of measurements. Most of these are quite expensive, often more than the listed price of your friend's scope.
Generally, no, especially if you don't have a good ground setup or don't understand about mains wiring (such as the difference between ground and neutral for example) and general knowledge of line voltage safety.
220V AC is actually over 600V peak-to-peak (+/- 311V), pretty close to the limit of your friend's scope. Your line voltage may actually be 230V, and maybe even higher than that, say by 10%, so as high as 253Vrms. That's 358V peak!
At that voltage all it would take is a spike from some other source, like a switch opening to a motor, light ballast, or some other inductive load to fry the scope input.
Then there's the question of grounding. The scope probe ground is the scope frame ground. If you just connect it across the line you have a 50-50 chance of connecting line voltage to ground- popping the breaker if you're lucky, but certainly doing bad things to the scope. How do you know? That business about neutral and ground I mentioned earlier: you need to understand this.
TL; DR version: no, it’s not safe.