6. Let $0<x<\pi$, then the minimum value of the function $y=\frac{2-\cos x}{\sin x}$ is ( ).
(A) 3
(B) $\sqrt{3}$
(C) 2
(D) $2-\sqrt{3}$
6. B.
$$
\begin{aligned}
y & =\frac{1}{\sin x}+\frac{1-\cos x}{\sin x}=\frac{1-\tan^2 \frac{x}{2}}{2 \tan \frac{x}{2}}+\tan \frac{x}{2} \\
& =\frac{1}{2 \tan \frac{x}{2}}+\frac{3}{2} \tan \frac{x}{2} . \\
\because 0 & < x < \pi, \quad \tan \frac{x}{2} > 0,
\end{aligned}
$$

i.e., $y \geqslant 2 \sqrt{\frac{1}{2 \tan \frac{x}{2}} \cdot \frac{3}{2} \tan \frac{x}{2}}=\sqrt{3}$, equality holds when $\tan \frac{x}{2} = \frac{\sqrt{3}}{3}, x=\frac{\pi}{3}$.