#!/usr/bin/env python
# encoding: utf-8
def test_args(*args):
for arg in args:
print arg
print test_args('hi', 24, 5)
运行上面这段代码控制台会多输出一个none是什么意思?
C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/demo/interpy/1.3.py
hi
24
5
None
Process finished with exit code 0
如果写成这样,最后不会多一个None:
你的写法多一个None是因为:函数
test_args
中没定义返回值,默认会返回None,当你print test_arg('hi', 24, 5)
的时候,就把函数的返回值None打印出来了。