打印乘法口诀表

for i in range(1, 10): for j in range(1, i+1): print(f' {j}{i}={ij}', end=' ') print()

将乘法口诀表写入文件 a.txt

with open('a.txt', 'w') as f: for i in range(1, 10): for j in range(1, i+1): f.write(f' {j}{i}={ij} ') f.write(' ')

读取文件 a.txt 并输出乘法口诀表

with open('a.txt', 'r') as f: print(f.read())

Python 打印乘法口诀表并写入文件

原文地址: https://www.cveoy.top/t/topic/omqJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录