摘要:
from time import sleep #时间模块引入sleep函数,用于缓冲 import os class Clock(object): def __init__(time,hour=0,minute=0,second=0): #时间初始化 time.hour = hour time.mi 阅读全文
摘要:
#os.walk()的作用就是遍历指定目录下的所有文件import os def fileDir(): fileDir = "E:" + os.sep + "学习程序" for i in os.walk(fileDir): print(i[0]) print(i[1]) print(i[2]) os 阅读全文
摘要:
import os def fileCopy(srcPath,desPath): # 判断拷贝文件是否存在 if not os.path.exists(srcPath): print("{}文件不存在".format(srcPath)) return # 判断是否是文件 if not os.path 阅读全文
摘要:
# 写文件with open("byh.txt","wt") as out_flie: out_flie.write("121431\n414")with open("byh.txt","rt") as in_file: text = in_file.read()print(text)输出结果: 1 阅读全文
摘要:
第一种方式:import syssys.stdout.write("请输入:\n")while True: line = sys.stdin.readline() if line == "\n": break else: print(line)第二种方式: import syss_line = sy 阅读全文
摘要:
#用户输入数字num = int(input("请输入一个数字: "))# 质数大于 1if num > 1: # 查看因子 for i in range(2, num): if (num % i) == 0: print(num, "不是质数") print(i, "乘于", num // i, 阅读全文