2011-09-28 35 views
47

Neden Python 9 satırındaki basit print deyiminde bir sözdizimi hatası veriyor?Python print ifadesi “Sözdizimi Hatası: geçersiz sözdizimi”

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 sürümü: Python 3

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

cevap

107

, baskı bir fonksiyondur, sen print("hello world") gibi demen gerekiyor.

7

Kullanım Python 3 print "Hello world" yılında print("use this bracket -sample text")

geçersiz sözdizimi hatası veriyor.

Python3'te dize içeriğini görüntülemek için bu ("Hello world") parantezlerini kullanmanız gerekir.