这是一个创建于 4064 天前的主题,其中的信息可能已经有所发展或是发生改变。
"".join(reduce(lambda i1,i2:i1+i2 ,[["*",str(len(argv)),"\r\n"]] + [["$",str(len(p)),"\r\n",p,"\r\n"] for p in map(str,argv)]))
搞定,如果加个头定义成函数就两行:
def parseCommand(*argv):
return "".join(reduce(lambda i1,i2:i1+i2 ,[["*",str(len(argv)),"\r\n"]] + [["$",str(len(p)),"\r\n",p,"\r\n"] for p in map(str,argv)]))
只需要 parseCommand("GET","MY-KEY") 就可以输出
*2\r\n$3\r\nGET\r\n$6\r\nMY-KEY\r\n
2 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
fd1207 2013-08-09 17:14:25 +08:00
你好,能否告知您的qq或电话等联系方式呢? 想请教一些python服务器方面的问题,,,
|