PaddlePaddle基础学习1

输出 9*9 乘法口诀表(注意格式)


def table():
    #在这里写下您的乘法口诀表代码吧!

    for i in range(1,10):
        for j in range(1,i+1):
            print(str(j) + str("*") + str(i)+"=" + str(i*j),end="\t")
        print()

if __name__ == '__main__':
    table()

**查找特定名称文件
遍历”Day1-homework”目录下文件;

找到文件名包含“2020”的文件;

将文件名保存到数组result中;

按照序号、文件名分行打印输出。

注意:提交作业时要有代码执行输出结果。**

#导入OS模块
import os
#待搜索的目录路径
path = "Day1-homework"
#待搜索的名称
filename = "2020"
#定义保存结果的数组
result = []

def findfiles(path):
    #在这里写下您的查找文件代码吧!
    files = os.listdir(path)
    for file in files:
        if os.path.isdir(os.path.join(path, file)):
            findfiles(os.path.join(path, file))
        else:
            if filename in file:
                # print(os.path.join(path, file))
                result.append(os.path.join(path, file))

if __name__ == '__main__':
    findfiles(path)

#  输出结果:
    i = 0
    for file in result:
        i+=1
        print(i ," :", file)


猜你喜欢

转载自blog.csdn.net/weixin_43850784/article/details/105765881