动态格式化字符串
a = [[1,2,3], [4,5,6],[7,8], [10,11,12,13,14]] for i in a: fmt = ‘%s ‘ * len(i) argvs = ‘‘.join(["i[%s], " % j for j in range(len(i)]) print fmt % eval(argvs)
获取当前登录用户
user = subprocess.Popen(‘who‘, shell=True, stdout=subprocess.PIPE) print list(set(user.stdout.read().split()[::5]))
原文地址:http://abian.blog.51cto.com/751059/1620786