老版本的建模软件修改rcbox

This commit is contained in:
dongchangxi committed 2023-10-22 19:08:41 +08:00
1 parent fb5a0683e9
commit f52f811b00
3 files changed
+24 -3

No files matched your search

+19 -2
View File
@@ -1,4 +1,4 @@
import redis,sys,os
import redis,sys,os,re
import platform
if platform.system() == 'Windows':
#sys.path.append('e:\\libs\\')
@@ -93,4 +93,21 @@ def copy_remote_directory(remote_host, remote_path, local_path):
# if __name__ == '__main__':
# redis_conn = config.redis_local_common
# print(redis_conn.sismember("photo3_no","1"))
# print(redis_conn.sismember("photo3_no","1"))
#读取rcbox文件进行修改指定的值
def change_rcbox_s(pid,new_value):
rcbox_path = os.path.join(config.workdir, pid, f"{pid}.rcbox")
old_value_pattern = r'<Residual s="([^"]+)"'
#读取文件内容
with open(rcbox_path, 'r') as f:
content = f.read()
#使用正则表达式进行匹配
match = re.search(old_value_pattern,content)
if match:
old_value = match.group(1)
new_content = re.sub(old_value_pattern,f'<Residual s="{new_value}"',content)
#重新写入进去
with open(rcbox_path, 'w') as f:
f.write(new_content)