2011-09-28 19 views
47

Dlaczego Python podaje mi błąd składniowy na prostej instrukcji print w wierszu 9?Python print statement "Błąd składniowy: nieprawidłowa składnia"

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","") 

Wersja Pythonie jest:

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

Odpowiedz

107

W Pythonie 3, druk jest funkcją, trzeba to nazwać jak print("hello world").

7

Zastosowanie print("use this bracket -sample text")

W Pythonie 3 print "Hello world" daje nieprawidłowy błąd składni.

Aby wyświetlić zawartość napisów w Pythonie 3, należy użyć nawiasów ("Hello world").

Powiązane problemy