码迷,mamicode.com
首页 > 编程语言 > 详细

python--循环&if

时间:2016-12-22 20:40:42      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:python

#!/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

标签:python

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!