If you separate your hits they aren't too bad to take care of (provided you're using a sword). You can hit one, most likely causing it to hiss, and then treat it like an angry girlfriend and back up by 8 blocks and give it time to calm down, then go in and hit it again, repeat. Depending on what your sword is made of, this shouldn't take very long at all.
You can also try attacking them from higher ground which usually won't set them off, though on rare occasions I've seen them decide after one or two hits that they were going to skip hissing and swelling altogether and just blow up instantly.
Of course, if you're less concerned about gunpowder and more concerned about mining you can strike one and take cover behind a 1-block-thick wall or so and tank the explosion. The wall will dampen the damage somewhat (you'll still probably get hurt) but in the process they'll dig up some blocks for you as well as (usually) take out any buddies they were bringing to the party.