用python实现本地文件扫描

#扫描文件
import os
def saomiao(wenjian):
    for i in os.listdir(wenjian):
        i1=os.path.join(wenjian,i)
        if os.path.isfile(i1):
            print(os.path.abspath(i1))
        elif os.path.isdir(i1):
            saomiao(i1)
        else:
            pass
saomiao("D:\\ak")

回文素数

#回文素数
def sushu(num):
    for i in range(2,num):
        if num % i == 0:
            break
    else:
        return num


def huiwenshu(num):
    ls = []
    if str(num) == str(num)[::-1]:
        ls.append(num)
    return ls


num = 2
ls = []
while len(ls)<100:
    if sushu(num) and huiwenshu(num):
            ls.append(num)
    num +=1
print(ls)

你可能感兴趣的:(python,开发语言)