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

python学习:函数传参数

时间:2017-09-13 18:27:47      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:nbsp   int   exit   函数传参   python学习   参数   /usr   执行   数字   

#!/usr/bin/python
 
import sys
 
def isNum(s):
    for i in s:
        if i in ‘0123456789‘:
           pass
        else:
            print "%s is not a number" %s
            sys.exit()
    else:
        print "%s is a number" %s
 
isNum(sys.argv[1])
 
//函数判断是否为数字 
 
执行结果:
python 12.py aa
aa is not a number
[root@web10 day02]# python 12.py 123
123 is a number
[root@web10 day02]# python 12.py 123d
123d is not a number

python学习:函数传参数

标签:nbsp   int   exit   函数传参   python学习   参数   /usr   执行   数字   

原文地址:http://www.cnblogs.com/weifeng1463/p/7516301.html

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