Python手动完成写作文件
我有一个程序,该程序从套件TCP/IP接收文件。BIN,但我不知道如何退出写作循环
是我的代码的一部分:
with open(f"recv_{FILENAME}", "wb") as f:
while True:
data = client_tcp.recv(1024)
if not data:
break
else:
f.write(data)
print("Data receiving")
if
#I want to go out the loop here if the file is completely received
print("File Received")
希望从所有人那里获得帮助。 非常感谢
I have a program which receive a file.BIN from socket TCP/IP but I don't know how to exit the writing loop
Here is a piece of my code:
with open(f"recv_{FILENAME}", "wb") as f:
while True:
data = client_tcp.recv(1024)
if not data:
break
else:
f.write(data)
print("Data receiving")
if
#I want to go out the loop here if the file is completely received
print("File Received")
Hope to get help from everybody.
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论