SyntaxError:Ubuntu Python 3终端上的语法无效

时间:2018-08-02 14:29:34

标签: python syntax-error

我是编码方面的新手,在黑暗中待了很长时间之后才回到现在,目前正在尝试完成一项作业,建议多谢!第13行语法错误

import os
#Imports operating system modules
user_file_search = raw_input('Type Millienium2000 ')
#Prompt the user to enter password
encoded = user_file_search.encode('hex')
#Decodes files based on hex

for root, dirs, files in os.walk ('/Desktop/POP/PoP_Coursework_Assignment/Svr1/documents$'):
    for data in files :
        pass_file = open(os.path.join(root,data)).read()

if(encoded in pass_file):
    print'This could be the pass : {}'.format(os.path.join(root,data))
    print 'Located data: {}'.format(pass_file)
#Prints Data retrieved

我被告知最初是通过终端出现的缩进问题,我花了一些时间纠正它,我相信,现在我遇到了

File "oswalk.py", line 13
print'This could be the pass : {}'.format(os.path.join(root,data))
SyntaxError: invalid syntax      ^

指向#{}' 在Ubuntu Python 3上编码 任何帮助,将不胜感激! 谢谢

1 个答案:

答案 0 :(得分:0)

欢迎使用Python 3 +,print现在不是关键字,而是函数,调用时需要用括号括起来:

    print ('This could be the pass : {}'.format(os.path.join(root,data)))
    print ('Located data: {}'.format(pass_file))