2011-09-28 12 views
47

पाइथन मुझे लाइन 9 पर सरल print कथन पर सिंटैक्स त्रुटि क्यों दे रहा है?पायथन प्रिंट स्टेटमेंट "सिंटेक्स त्रुटि: अमान्य वाक्यविन्यास"

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 3.2.2 (default, Sep 4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win 
32 

उत्तर

107

अजगर 3 में, प्रिंट एक समारोह है, तो आप इसे print("hello world") की तरह कॉल करने के लिए की जरूरत है।

7

उपयोग print("use this bracket -sample text")

अजगर 3 print "Hello world" में अमान्य सिंटैक्स त्रुटि देता है।

पायथन 3 में स्ट्रिंग सामग्री प्रदर्शित करने के लिए इस ("Hello world") ब्रैकेट का उपयोग करना होगा।

संबंधित मुद्दे