0.1.200
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.199
|
version = 0.1.200
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.4
|
Metadata-Version: 2.4
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.1.199
|
Version: 0.1.200
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ def logging_with_day_and_time(content='', filename='time_logging', file_format='
|
|||||||
else:
|
else:
|
||||||
f2.write(datetime_today+' '+datetime_time+' '+str(content)+'\n')
|
f2.write(datetime_today+' '+datetime_time+' '+str(content)+'\n')
|
||||||
|
|
||||||
|
# 获取当前位置的 Unix 时间戳,并打印某段程序的运行时间
|
||||||
|
def record_time_and_print_running_time(start_time=None):
|
||||||
|
import time
|
||||||
|
current_time = time.time()
|
||||||
|
if start_time == None:
|
||||||
|
print("\n--- 开始计时(第一个记录点)---\n")
|
||||||
|
else:
|
||||||
|
print(f"\n--- 自上一个记录点已运行: {current_time - start_time:.2f} 秒 ---\n")
|
||||||
|
return current_time
|
||||||
|
|
||||||
# 使用该函数运行某个函数并获取函数计算时间(秒)
|
# 使用该函数运行某个函数并获取函数计算时间(秒)
|
||||||
def timer(function_name, *args, **kwargs):
|
def timer(function_name, *args, **kwargs):
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -126,6 +126,29 @@ def get_links_from_pdf(pdf_path, link_starting_form=''):
|
|||||||
old = u['/A']['/URI']
|
old = u['/A']['/URI']
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
# 将某个文件夹中的某个类型的文本文件全部修改为另外一个编码,其他文件不变
|
||||||
|
def convert_file_encoding_for_one_directory(source_directory, target_directory, file_formats=['.m'], src_encoding='utf-8', dst_encoding='gb18030'):
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
os.makedirs(target_directory, exist_ok=True)
|
||||||
|
for root, dirs, files in os.walk(source_directory):
|
||||||
|
rel_path = os.path.relpath(root, source_directory)
|
||||||
|
target_subdir = os.path.join(target_directory, rel_path) if rel_path != '.' else target_directory
|
||||||
|
os.makedirs(target_subdir, exist_ok=True)
|
||||||
|
for file in files:
|
||||||
|
src_file = os.path.join(root, file)
|
||||||
|
dst_file = os.path.join(target_subdir, file)
|
||||||
|
if any(file.lower().endswith(ext.lower()) for ext in file_formats):
|
||||||
|
try:
|
||||||
|
with open(src_file, 'r', encoding=src_encoding) as f:
|
||||||
|
content = f.read()
|
||||||
|
with open(dst_file, 'w', encoding=dst_encoding) as f:
|
||||||
|
f.write(content)
|
||||||
|
except Exception as e:
|
||||||
|
shutil.copy2(src_file, dst_file)
|
||||||
|
else:
|
||||||
|
shutil.copy2(src_file, dst_file)
|
||||||
|
|
||||||
# 获取当前日期字符串
|
# 获取当前日期字符串
|
||||||
def get_date(bar=True):
|
def get_date(bar=True):
|
||||||
import datetime
|
import datetime
|
||||||
|
|||||||
Reference in New Issue
Block a user