python 简单的创建文本实现''九九乘法表''

九九乘法表

with open("99cfb.txt","w",encoding="utf-8") as doc:
    for i in range(1,10):
            for j in range(1,i):
                    print(j,"*",i,"=",j*i,end=" ",file=doc)
            print(file=doc)
使用 with open 可直接创建文本,括号里有3个说明,第一个即是生成文件名字,第二个即是"用户权限","r"为只读,即是"read","w"为写入,即是"write",第三个是编码wenj 式写入时根据需要填写,中文一般是"utf-8"  "file = doc" 即是表示存入doc  doc 就是txt文件

你可能感兴趣的:(python,九九乘法表,简单编程)