【发布时间】:2018-08-02 16:31:19
【问题描述】:
基本上我在第 3 行遇到了关于类型错误的问题,我收到“TypeError: 'str' object is not callable” 任何建议将不胜感激 /Ubuntu/python3/terminal
import os
#Imports operating system modules
user_file_search = 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 retrived
我收到以下内容
Traceback(最近一次调用最后一次):
文件“oswalk.py”,第 3 行,在
user_file_search = input()('Type Millienium2000')
TypeError: 'str' 对象不可调用
提前致谢!
更新!代码现在运行得非常好!谢谢大家! 我遇到了一个新问题,被告知
文件“oswalk.py”,第 5 行,
编码 = user_file_search.encode('hex') LookupError: 'hex' 不是文本编码;使用 codecs.encode() 处理任意编解码器
我搜索的所有文件都是用 HEX 编码的,是因为有 hex 的替代输入吗?
【问题讨论】:
-
去掉空括号!
-
input('Type Millienium2000')。以错字结尾。 -
您是否要在输入之前打印该语句?如果是这样,您将字符串放在输入调用中:
input('Type Millienium2000')。您不能添加额外的括号并以这种方式调用它 -
啊,非常感谢,有趣的是,休息后重新编码是多么困难! , 这解决了我的问题。