本文介绍了如何在Python中摆脱None的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import sys
import socket
import time
ip=([(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])


x="........"

def print_word_slowly(word):
    for i in word:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.2)
        
        
        
print "Loading...\n"
print print_word_slowly("obtaining IP address......."), "     \nIP Address obtained. IP Address is %s."%(ip)







打印出:




This prints out:

Loading...                                                                                                                               
                                                                                                                                         
obtaining IP address.......None                                                                                                          
IP Address obtained. IP Address is 172.17.29.xxx.



如何在获取IP地址后摆脱'无'.......


How can I get rid of 'None' after 'obtaining IP address.....'?

推荐答案



这篇关于如何在Python中摆脱None的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 04:58