I am a beginner in algebraic geometry. I encountered such a question in the book which I read.
Suppose that $X$ is an affine variety and $U$ is an open subset of $X$ (so that $U$ is a quasi-affine variety). Suppose that $p\in U.$ Show that $\mathcal O_{U,p} =\mathcal O_{X,p}$.
$\mathcal O_{X.p}=\bigcup_{p\in U}\mathcal O_{X}(U)$, $\mathcal O_X(U)$ is the regular function on $U$. Similarly, $\mathcal O_{U.p}=\bigcup_{p\in V}\mathcal O_{U}(V)=\bigcup_{p\in V}\mathcal O_{X}(V)$, where the union in $k(U)$ is over all open sets $V$ in $U$ containing $p$.
Since $V$ is a open subset of $U$, $V$ itself is again a quasi-affine variety, and $U$ and $V$ have the same function field $k(X)$.
How do I get those two are equal?
I'll expand on reun's comment a little. Your definitions of local rings seem incorrect. One way to define them is $\mathcal{O}_{X,p} := \{(U, f): f \in \mathcal{O}_X(U)\}/\sim$ where the equivalence relation is defined as $(U,f) \sim (V, g)$ iff there is an open subset $W \subseteq U \cap V$ such that $f|_{W} = g|_{W}$. In this setting the desired statement is very easy. Consider the map $\mathcal{O}_{X,p} \rightarrow \mathcal{O}_{U,p}$ that sends the equivalence class of $(V, f)$ to the equivalence class of $(V \cap U, f|_{V \cap U})$. It is straightforward to see that this is well defined and injective. Surjectivity is easy as well since any equivalence class $(W, f) \in \mathcal{O}_{U,p}$ is mapped to by the equivalence class $(W, f) \in \mathcal{O}_{X,p}$ as if $W \subseteq U$ is open then certainly $W \subseteq X$ is open.