首页 > 编程语言 > 详细

python--循环&if

时间:2016-12-22 20:39:58      阅读:126      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python
import socket
#solist = [x for x in dir(socket) if x.startswith("SO_")]
#solist.sort()
#for x in solist:
#    print x

def fun():
    for x in dir(socket):
        if x.startswith("SO_"):
            print x
fun()

再python中循环和判断可以放在一起:

solist = [x for x in dir(socket) if x.startswith("SO_")]

这句含义和下面的函数中起到一样的作用:



本文出自 “自定义” 博客,谢绝转载!

python--循环&if

原文:http://zidingyi.blog.51cto.com/10735263/1885126

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!