This sentence compares an inexperienced heart to an unguarded city in a metaphorical way, which means that if we can keep our heart firm and pure and free from external interference and erosion, we can win on the battlefield of life, just as an army can seize an unguarded city.
This also reminds us that only by maintaining inner strength and self-confidence, not being influenced by external negative factors and always maintaining a positive attitude can we achieve more success and victory on the road of life.