# 【日常】轻松一刻：python传参还能这么写

def f(a,b=1,c=2,d=3):
print("a: {}".format(a))
print("b: {}".format(b))
print("c: {}".format(c))
print("d: {}".format(d))

def myFunction(f,lst):
""" Edit Start """
""" Edit End """
pass

lst1 = [1]
lst2 = [1,3]
lst3 = [1,3,5]
lst4 = [1,3,5,7]

myFunction(f,lst1)
myFunction(f,lst2)
myFunction(f,lst3)
myFunction(f,lst4)

def f1(a,*args,**kwargs):
print(a)
print(args)
print(kwargs)

f1(1,2,3,4,b=1,c=2)

# 输出
"""
1
(2, 3, 4)
{'b': 1, 'c': 2}
"""

def f(a,b=1,c=2,d=3):
print("a: {}".format(a))
print("b: {}".format(b))
print("c: {}".format(c))
print("d: {}".format(d))

def myFunction(f,lst):
""" Edit Start """
if len(lst)==1: f(lst[0])
elif len(lst)==2: f(lst[0],lst[1])
elif len(lst)==3: f(lst[0],lst[1],lst[2])
elif len(lst)==4: f(lst[0],lst[1],lst[2],lst[3])
else: assert False
""" Edit End """
pass

lst1 = [1]
lst2 = [1,3]
lst3 = [1,3,5]
lst4 = [1,3,5,7]

myFunction(f,lst1)
myFunction(f,lst2)
myFunction(f,lst3)
myFunction(f,lst4)


def f(a,b=1,c=2,d=3):
print("a: {}".format(a))
print("b: {}".format(b))
print("c: {}".format(c))
print("d: {}".format(d))

def myFunction(f,lst):
""" Edit Start """
string = "f("
for i in range(len(lst)):
string += "lst[{}],".format(i)
string += ")"
eval(string)
""" Edit End """
pass

lst1 = [1]
lst2 = [1,3]
lst3 = [1,3,5]
lst4 = [1,3,5,7]

myFunction(f,lst1)
myFunction(f,lst2)
myFunction(f,lst3)
myFunction(f,lst4)

eval("f(lst[0],lst[1],lst[2],lst3)")      # 可行
f(eval("lst[0],lst[1],lst[2],lst[3]"))    # 不可行

import multiprocessing
def do(n) :
#获取当前线程的名字
name = multiprocessing.current_process().name
print(name,'starting')
print("worker ",n)

if __name__ == '__main__' :
numList = []
for i in range(5):
p = multiprocessing.Process(target=do, args=(i,))
numList.append(p)
p.start()
p.join()
print("Process end.")

class BaseProcess(object):
'''
Process objects represent activity that is run in a separate process

The class is analogous to threading.Thread
'''
def _Popen(self):
raise NotImplementedError

def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
*, daemon=None):
assert group is None, 'group argument must be None for now'
count = next(_process_counter)
self._identity = _current_process._identity + (count,)
self._config = _current_process._config.copy()
self._parent_pid = os.getpid()
self._popen = None
self._target = target
self._args = tuple(args)
self._kwargs = dict(kwargs)
self._name = name or type(self).__name__ + '-' + \
':'.join(str(i) for i in self._identity)
if daemon is not None:
self.daemon = daemon

def run(self):
'''
Method to be run in sub-process; can be overridden in sub-class
'''
if self._target:
self._target(*self._args, **self._kwargs)

def f(a,b=1,c=2,d=3):
print("a: {}".format(a))
print("b: {}".format(b))
print("c: {}".format(c))
print("d: {}".format(d))

def myFunction(f,lst):
""" Edit Start """
f(*lst)
""" Edit End """
pass

lst1 = [1]
lst2 = [1,3]
lst3 = [1,3,5]
lst4 = [1,3,5,7]

myFunction(f,lst1)
myFunction(f,lst2)
myFunction(f,lst3)
myFunction(f,lst4)

08-19 2147

11-30 1883

01-18 1347

08-20 2367

03-21 2323

12-23 181

03-10 39

12-29 925

12-20 2398

10-31 35

#### Appium Android Bootstrap源码分析之命令解析执行

©️2020 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。