\documentclass{article}

\usepackage{pythontex}
\usepackage{tikz}

\begin{document}

\begin{pycode}
print(r'This is python.')
\end{pycode}

\begin{tikzpicture}

\begin{pycode}
print(r'\node {This is python};')
\end{pycode}

\end{tikzpicture}

\end{document}
