PaddlePaddle basic learning 1

Output 9*9 multiplication formula table (note the format)


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()

**Find a file with a specific name,
traverse the files in the "Day1-homework" directory;

Find the file whose file name contains "2020";

Save the file name to the array result;

Print the output in line according to the serial number and file name.

Note: There must be code execution output results when submitting the job. **

#导入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)


Guess you like

Origin blog.csdn.net/weixin_43850784/article/details/105765881