80 Star 595 Fork 260

编程语言算法集 / Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
receive_file.py 585 Bytes
一键复制 编辑 原始数据 按行查看 历史
NIKITA PANDEY 提交于 2023-03-31 19:38 . Update receive_file.py (#8541)
import socket
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname()
port = 12312
sock.connect((host, port))
sock.send(b"Hello server!")
with open("Received_file", "wb") as out_file:
print("File opened")
print("Receiving data...")
while True:
data = sock.recv(1024)
if not data:
break
out_file.write(data)
print("Successfully received the file")
sock.close()
print("Connection closed")
if __name__ == "__main__":
main()
Python
1
https://gitee.com/TheAlgorithms/Python.git
git@gitee.com:TheAlgorithms/Python.git
TheAlgorithms
Python
Python
master

搜索帮助