|
发表于 2024-6-8 00:22:29
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import socket,json
class myftp():
def ls(self, *args):
print(args)
print("ls 命令里。。。。。")
def put(self):
pass
def download(self):
pass
client=socket.socket()
client.connect(('localhost',6969))
msg_dic={
'action':'',
'filename':'',
'filesize':0,
'ouerwrite':False
}
while True:
str=input(">>>>:").strip()
if len(str)==0:
continue
msg_dic['action']=str.split()[0]
if ' in str:
msg_dic['filename']=str.split()[1]
else:
msg_dic['filename']=''
if hasattr(myftp,msg_dic['action']):
try:
fun=getattr(myftp,msg_dic['action'])
fun(msg_dic)
except Exception as e:
print(f"执行命令时出错: {e}")
else:
print("无效的命令")
client.close()
运行结果为什么是类myftp里的ls接收不到字典参数呢。郁闷中.。。。。。。 |
|