In QGIS 3.0 it is very easy. For instance our EPSG is 2320:

<!-- language: pyqgis -->

    QgsProject.instance().setCrs(QgsCoordinateReferenceSystem(2320))