ActiveSheet.Pictures.Insert( _
"\\Jz\2023\12\12.29-0.15\10K\1-2-3.jpg").Select
import re
# 假设你的文本保存在一个名为text的变量中
text = """
...
ActiveSheet.Pictures.Insert( _
"\\Jz\2023\12\12.29-0.15\10K\1-2-3.jpg").Select
...
"""
# 使用正则表达式找到所有的"10K"并替换为"8K"
new_text = re.sub(r'(\d+K)', '8K', text)
print(new_text)
import re
your_file_path=r'C:\Users\Desktop\test.txt'
# 读取文件内容
with open(your_file_path, 'r') as file:
content = file.read()
# 使用正则表达式找到所有的"10K"并替换为"8K"
new_text = re.sub(r'(\d+K)', '8K', content)
# 将替换后的内容写回文件
with open(your_file_path, 'w') as file:
file.write(new_text)
结果:
ActiveSheet.Pictures.Insert( _
"\\Jz\2023\12\12.29-0.15\8K\1-2-3.jpg").Select