我有这个python脚本,我需要运行 gdal_retile.py
但我在这一行得到一个例外:
if Verbose:
print("Building internam Index for %d tile(s) ..." % len(inputTiles), end=' ')
Run Code Online (Sandbox Code Playgroud)
将end=''是无效的语法.我很好奇为什么,以及作者可能打算做什么.
如果你还没有猜到,我是python的新手.
我认为问题的根本原因是这些导入失败,因此必须包含此导入 from __future__ import print_function
try:
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
from osgeo.gdalconst import *
except:
import gdal
import ogr
import osr
from gdalconst import *
Run Code Online (Sandbox Code Playgroud) 为什么Python print在第9行的简单语句中给出了语法错误?
import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = raw_input("What is the file name in which the hash resides? ")
wordlist = raw_input("What is your wordlist? (Enter the file name) ")
try:
hashdocument = open(hash_file,"r")
except IOError:
print "Invalid file." # Syntax error: invalid syntax
raw_input()
sys.exit()
else:
hash = hashdocument.readline()
hash = hash.replace("\n","")
Run Code Online (Sandbox Code Playgroud)
Python的版本是:
Python 3.2.2 (default, Sep 4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win
32
Run Code Online (Sandbox Code Playgroud)