随笔分类 - Python
摘要:import os import sys def copy_file(srcfile, dstpath): if not os.path.isfile(srcfile): print("{} 文件不存在".format(srcfile), flush=True) sys.exit(1) else:
阅读全文
摘要:def replace_contents(old_content, new_content, file_path): file_data = "" with open(file_path, "r", encoding="UTF-8") as f: for line in f: if old_cont
阅读全文
摘要:import threading mutex_lock = threading.RLock() class Threads(threading.Thread): def __init__(self,name): threading.Thread.__init__(self) def run(self
阅读全文
摘要:重写unittest import unittest class ParametrizedTestCase(unittest.TestCase): """ TestCase classes that want to be parametrized should inherit from this c
阅读全文
摘要:代码编码: python编码 1、国际惯例,文件编码和 Python 编码格式全部为 utf-8 ,例如:在 Python 代码的开头,要统一加上 # -- coding: utf-8 --。 2、Python 代码中,非 ascii 字符的字符串,请需添加u前缀 3、若出现 Python编 码问题
阅读全文