递归打印多维列表
__author__ = 'Administrator'

cast = ['a','b','c','d',['aa','bb','cc',['aaa','bbb','ccc']]]
print(cast)
def print_lol(the_list):
    for each_item in the_list:
        if isinstance(each_item,list):
            print_lol(each_item)
        else:
            print(each_item)
print_lol(cast)

"打印结果"

[‘a’, ‘b’, ‘c’, ‘d’, [‘aa’, ‘bb’, ‘cc’, [‘aaa’, ‘bbb’, ‘ccc’]]]
a
b
c
d
aa
bb
cc
aaa
bbb
ccc

python清空文件夹下log文件

#!/usr/bin/python import os import sys files_list = [] def print_files(path): lsdir = os.listdir(path) dirs = [i for i in lsdir if os.path...

阅读全文

python paramiko(SFTP) 相关文档

python paramiko SFTP文档地址: http://docs.paramiko.org/en/2.4/api/sftp.html import paramiko host = "THEHOST.com" #...

阅读全文

python 执行cmd命令并获取pid

process = subprocess.Popen('cmd命令') pid = process.pid print(pid)

阅读全文

欢迎留言