python socket send 无效_python socket send()命令没有

我需要写一个服务器和一个cliet做4件事

1.发送收到消息的时间

2.把所有的文件放在一个文件夹里

3.从该文件夹复制一个文件,并在另一个文件夹中创建一个新文件(txt)

4关闭程序

克林特:import socket

import os

import pickle

s=socket.socket()

addr=('127.0.0.1',8200)

s.connect(addr)

choice="0"

while choice!="4":

print s.recv(4068)

choice=raw_input("please choose a service number:")

s.send(choice)

if choice=="3":

fileName=raw_input("please enter the name of the file you want to download:")

s.send(fileName)

data2= s.recv(4068)

if choice=="1":

print data2

elif choice=="2":

data_arr=pickle.loads(data2)

print data_arr

elif choice=="3":

text=s.recv(4068)

if text=="no file with this name":

print text

else:

newFile=open("newFile.txt","w")

newFile.write(text)

newFile.close()

print "thanks for using our conection"

s.close()

服务器:

^{pr2}$

问题是我在另一台电脑上试过了,但是progrem没有发送消息(粗体),我不明白为什么因为代码在另一台电脑上工作,经过几次测试我知道它找到了文件,一切正常,它只是不发送消息(txt文件不是空的)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值