我使用PyQGIS Cookbook學習PyQGIS,併購買了PyQGIS程序員指南。我已經能夠使用小腳本加載圖層,但沒有運氣將項目加載到QGIS中。我不斷收到第13行的'SyntaxError:invalid syntax'。我正在使用QGIS中的Python控制檯並鍵入'import _loadproject'來啓動腳本。如何使用PyQGIS將項目加載到QGIS?
有人可以指出我要去哪裏嗎?
"""Load Project: This is to test loading a project."""
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from qgis.core import *
from qgis.utils import iface
class ProjectScript:
def __init__(self, iface):
self.iface = iface
def load_project(self)
project = QgsProject.instance() \
project.read(QFileInfo('S:/SOCAL/Section_28/SOCAL_CK47/Control_Data/SOCAL_CK47_project.qgs'))
print project.fileName 'S:/SOCAL/Section_28/SOCAL_CK47/Control_Data/SOCAL_CK47_project.qgs'
def run_script(iface):
"""Run the script by loading and calling LoadProject methods."""
fs = ProjectScript(iface)
fs.load_project()
in line 13你在load_project函數中沒有「:」def load_project(self):「 –