我的Python程序没有显示输出 [英] My Python program not showing output

查看:358
本文介绍了我的Python程序没有显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python 3.4.3中编写了一个Python程序,但它没有显示任何输出。我怎么能得到outpu请帮助



我尝试过:



I wrote a Python program in python 3.4.3 But it is not showing any output. how can i get outpu please help

What I have tried:

import socket
mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
mysock.connect(("www.py4inf.com",80))
mysock.send("GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n".encode('ascii'))
while True:
	data=mysock.recv(512)
	if(len(data)<1):
            break
            print (data.decode('ascii'))
mysock.close()

推荐答案

if(len(data)<1):
        break
        print (data.decode('ascii'))



因此,如果数据长度小于1,则在循环时突破 。如果它等于或大于1,则继续循环。但在任何一种情况下,你都不会到达打印声明。


So if the length of the data is less than 1 you break out of the while loop. If it is equal or greater than 1 you continue the loop. But in either case you never reach the print statement.


这篇关于我的Python程序没有显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆