jjzjj

argument

全部标签

Python 错误 : X() takes exactly 1 argument (8 given)

我正在尝试构建一个匿名FTP扫描器,但我在调用函数X时遇到错误,我将X定义为接收1个参数,即ip地址,如果我不使用循环,则相同的代码有效并一一发送IP。错误是:X()恰好接受1个参数(给定8个)fromftplibimportFTPimportipcalcfromthreadingimportThreaddefX(ip):try:ftp=FTP(ip)x=ftp.login()if'ogged'instr(x):print'[+]Bingo!wegotaAnonymousFTPserverIP:'+ipexcept:returndefmain():globalipforipinipca

python - psycopg2 "TypeError: not all arguments converted during string formatting"

我正在尝试将二进制数据(漩涡哈希)插入PG表,但出现错误:TypeError:notallargumentsconvertedduringstringformatting代码:cur.execute("""INSERTINTOsessions(identity_hash,posted_on)VALUES(%s,NOW())""",identity_hash)我尝试在插入之前将conn.Binary("identity_hash")添加到变量中,但得到了同样的错误。identity_hash列是一个bytea。有什么想法吗? 最佳答案

python - "OSError: [Errno 22] Invalid argument"读取一个大文件时

我正在尝试编写一个打印文件校验和的小脚本(使用来自https://gist.github.com/Zireael-N/ed36997fd1a967d78cb2的一些代码):importsysimportosimporthashlibfile='/Users/Me/Downloads/2017-11-29-raspbian-stretch.img'withopen(file,'rb')asf:contents=f.read()print('SHA256offileis%s'%hashlib.sha256(contents).hexdigest())但我收到以下错误消息:Traceback

Python 参数解析 : "unrecognized arguments"

我正在尝试通过命令行选项使用我的程序。这是我的代码:importargparsedefmain():parser=argparse.ArgumentParser()parser.add_argument("-u","--upgrade",help="fullyautomatizedupgrade")args=parser.parse_args()ifargs.upgrade:print"Startingwithupgradeprocedure"main()当我尝试从终端(pythonscript.py-u)运行我的程序时,我希望收到消息Startingwithupgradeproced

python - 类型错误 : split() takes no keyword arguments in Python 2. x

我试图将文档的一部分分成不同的部分,这些部分由&符号分隔。这是我的:name,function,range,w,h,k,frac,constraint=str.split(str="&",num=8)错误:TypeError:split()takesnokeywordarguments有人可以向我解释错误并提供替代方法让我完成这项工作吗? 最佳答案 str.split的参数分别称为sep和maxsplit:str.split(sep="&",maxsplit=8)但是你只能在Python3.x中使用这样的参数名称。在Python2.

python - 类型错误 : count() takes exactly one argument

我是Python和Django的新手,我根据教程修改了这段代码。我在加载页面时收到TypeError:count()takesexactlyoneargument(0given)。我一直在进行故障排除和谷歌搜索,但似乎无法弄清楚。我做错了什么?defreport(request):flashcard_list=[]forflashcardinFlashcard.objects.all():flashcard_dict={}flashcard_dict['list_object']=flashcard_listflashcard_dict['words_count']=flashcard

python - 在子命令后允许 argparse 全局标志

我正在使用argparse构建带有子命令的命令:mycommand[GLOBALFLAGS]子命令[FLAGS]我希望全局标志在子命令之前或之后都有效。有没有不涉及重复代码的简洁方法?例如:parser=argparse.ArgumentParser()subparsers=parser.add_subparsers(dest='subparser_name')parser.add_argument('--disable')#Thisflag...sp=subparsers.add_parser('compile')sp.add_argument('zones',nargs='*')s

python - 操作系统错误 : [Errno 22] Invalid argument in subprocess

python3.3.3Windows7Hereisthefullstack:Traceback(mostrecentcalllast):File"Blah\MyScript.py",line578,inCalloutput=process.communicate(input=SPACE_KEY,timeout=600)File"C:\Python33\lib\subprocess.py",line928,incommunicatestdout,stderr=self._communicate(input,endtime,timeout)File"C:\Python33\lib\subp

Python argparse : default argument stored as string, 未列出

我无法从文档中找出argparse的这种行为:importargparseparser.add_argument("--host",metavar="",dest="host",nargs=1,default="localhost",help="Nameofhostfordatabase.Defaultis'localhost'.")args=parser.parse_args()print(args)这是带和不带“--host”参数的输出:>>pythondemo.pyNamespace(host='localhost')>>pythondemo.py--hosthostNamesp

【Android】解决:Could not find method android() for arguments报错

报错信息:结果图原因报错的意思是说:在我项目的build.grandle文件报错了,重建不了,是因为缺少一个参数。然后我就去百度,哈哈哈,有问题找百度。解决办法百度给出了三种解决方案:1、项目要求的sdk版本和我导入项目的SDK版本不匹配,导致了这个问题;所以,我去比对了:TaegetSDK:32导入SDK:打开路劲;排除SDK版本不匹配问题,因为我导入项目的也是32。2、去prostructure中修改你的API版本,我感觉不是这个问题,所以我没试过,大家可以参考:Couldnotfindmethodandroid()forarguments的方法3、这个就是突然注意到,我的build.gr