No, educating children requires preaching and teaching. You can't preach blindly, which is easy to cause children's rebellion, and you can't just do it. Children's understanding ability is not strong enough, so we need to tell them how to understand and why in real time.
When educating children, we must know how to set an example. Since we want to educate children not to swear, we must first be ourselves. If we don't swear, this is the right thing to do. Only if we don't swear, the children will do as you say, and we should also purify the environment around the children. If children learn from others, we should also guide them to develop in a good way, tell them that these are all wrong and make them willing.