一尘不染

Python打印语句“语法错误:语法无效”

python

为什么Pythonprint在第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","")

Python的版本是:

Python 3.2.2 (default, Sep  4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win
32

阅读 159

收藏
2020-12-20

共1个答案

一尘不染

在Python 3中,print是一个函数,您需要像这样调用它print("hello world")

2020-12-20