【Python】Learn Python the hard way, ex18 def函数
2015-10-11 16:38
555 查看
# this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1: %r ,arg2: %r" % (arg1, arg2) # ok, that *args is actually pointless, we can just do this def print_two_again(arg1, arg2): print "arg1: %r, arg2: %r" % (arg1, arg2) # this just takes one argument def print_one(arg1): print "arg1: %r" % arg1 # this one takes no arguments def print_none(): print "I got nothin'." print_two("Hong","Qi") print_two_again("Hong","Qi") print_one("First!") print_none() ''' Test Result: arg1: 'Hong' ,arg2: 'Qi' arg1: 'Hong', arg2: 'Qi' arg1: 'First!' I got nothin'. '''
这些都是基本功,没啥好说的
相关文章推荐
- python编译器IDLE的问题。
- python 编码问题
- Python基础
- 使用 timeit 模块
- Python 进制转换
- Python模块常用的几种安装方式
- python split做简易计算器
- LeetCode----Subsets II
- python 模块 包
- 有关Python的内容
- leetcode-Count Primes 以及python的小特性
- python 环境的配置和pip 的安装
- Python 基础语法(二)
- Python Scapy(2.3.1)文档学习(五):构建自己的工具
- python开发_常用的python模块及安装方法
- Python 基础语法(一)
- 3.3.8 使用difflib.ndiff函数
- leetcode之H-index II
- 开始学习Python了,每天都要有进步啊
- Python获取两个日期间的所有日期