摘要: from time import sleep #时间模块引入sleep函数,用于缓冲 import os class Clock(object): def __init__(time,hour=0,minute=0,second=0): #时间初始化 time.hour = hour time.mi 阅读全文
posted @ 2019-12-09 12:01 Agoni丶 阅读(282) 评论(0) 推荐(0)
摘要: import re def is_valid_email(addr): #[\w]匹配至少一个数字、字母、下划线的字符;[\W]不匹配“-“”字符;“.”匹配除了\n的任意字符 pattern = re.compile(r"^[\w]+(\.[\W]+)*@+[\w]+(\.[\w])+") res 阅读全文
posted @ 2019-12-06 23:17 Agoni丶 阅读(1506) 评论(0) 推荐(0)
摘要: os.chdir()作用是修改文件路径 import os path = "D:" fileDir = os.getcwd() #读取当前路径 print("当前目录为:%s"% fileDir) os.chdir(path) #修改路径 fileDir = os.getcwd() #查看修改后路径 阅读全文
posted @ 2019-12-05 13:28 Agoni丶 阅读(2310) 评论(0) 推荐(0)
摘要: #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 阅读全文
posted @ 2019-12-05 12:49 Agoni丶 阅读(211) 评论(0) 推荐(0)
摘要: import os def fileCopy(srcPath,desPath): # 判断拷贝文件是否存在 if not os.path.exists(srcPath): print("{}文件不存在".format(srcPath)) return # 判断是否是文件 if not os.path 阅读全文
posted @ 2019-12-03 22:07 Agoni丶 阅读(130) 评论(0) 推荐(0)
摘要: # 写文件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 阅读全文
posted @ 2019-12-01 15:58 Agoni丶 阅读(105) 评论(0) 推荐(0)
摘要: 第一种方式:import syssys.stdout.write("请输入:\n")while True: line = sys.stdin.readline() if line == "\n": break else: print(line)第二种方式: import syss_line = sy 阅读全文
posted @ 2019-12-01 15:57 Agoni丶 阅读(240) 评论(0) 推荐(0)
摘要: filename = "./by.txt"objFile = open(filename,"r+") #需要从末尾定义时,须使用“rb”模式# 读取5个 .readstr = objFile.read(5)print("当前字符串读取的为:",str)# 指出当前光标位置 .tellposi = o 阅读全文
posted @ 2019-12-01 15:56 Agoni丶 阅读(222) 评论(0) 推荐(0)
摘要: #用户输入数字num = int(input("请输入一个数字: "))# 质数大于 1if num > 1: # 查看因子 for i in range(2, num): if (num % i) == 0: print(num, "不是质数") print(i, "乘于", num // i, 阅读全文
posted @ 2019-11-29 17:28 Agoni丶 阅读(1444) 评论(0) 推荐(0)
摘要: def demo(a,b): a,b = b,a print(a,b) a = 10 b = 20 demo(a,b) 输出结果: 20 10 阅读全文
posted @ 2019-11-29 16:54 Agoni丶 阅读(348) 评论(0) 推荐(0)