A. You have two options:
a. Withdraw Money from 401K
Generally you can't withdraw money from your 401(k) until you leave your job. But you can use hardship withdrawals which different plans have different requirements. Generally you have to satisfy "heavy and immediate financial need" for major expenses such as home repairs resulting from a casualty loss (storms, fires, floods, etc.), a home purchase or uninsured medical expenses.
Unless the money is from your Roth 401(k), you will have to pay tax in your top tax bracket, plus a 10% early withdrawal penalty if you are younger than 59.5. If most cases, you must stop making contributions to 401(k) for up to six months.
b. Take Loan from 401K
The better approach maybe taking a 401(k) loan, you can borrow 50% of your balance, up to $50,000 for any reason without taxes or early penalties. You have to pay interest, but it will go back to your own account.
The only caveat is you will have to pay back the loan in 60 to 90 days if you leave your current job, otherwise your loan will be taxed as income and you will have to penalty as well.