写一段Python代码: 使用正则表达式,筛选出指定txt文档中“VREF_BF_TRIM= 584.0MV”中间的数字,并另存为一个叫“OK”的txt文件中
时间: 2024-05-12 17:18:44 浏览: 142
```python
import re
# 打开原始文本文件
with open("original.txt", "r") as f:
content = f.read()
# 使用正则表达式匹配数字
match = re.search(r"VREF_BF_TRIM=\s*(\d+(\.\d+)?)MV", content)
if match:
# 提取匹配到的数字
num = match.group(1)
# 将数字保存到新的文本文件中
with open("OK.txt", "w") as f:
f.write(num)
else:
print("No match found.")
```
其中,`original.txt`为指定的文本文件名,`VREF_BF_TRIM= 584.0MV`为待匹配的字符串,数字`584.0`将被提取并保存到新的文本文件`OK.txt`中。如果没有匹配到,则输出提示信息。
相关问题
写一段Python代码: 使用正则表达式,筛选出指定txt文档中“VREF_BF_TRIM= 584.0MV”中间的数字,然后将筛选出来的所有数字分别存进一个叫“OK”的xlsx的单元格中
import re
import openpyxl
# 打开txt文档
with open('example.txt', 'r') as f:
content = f.read()
# 使用正则表达式筛选出数字
pattern = r'VREF_BF_TRIM=\s+(\d+\.\d+)MV'
match_list = re.findall(pattern, content)
# 将数字存进xlsx单元格中
wb = openpyxl.Workbook()
ws = wb.active
for i in range(len(match_list)):
ws.cell(row=i+1, column=1, value=float(match_list[i]))
wb.save('OK.xlsx')
Read Spd Begin... The memory on CH :1 are different! N: pre svc call fun = 0xc2000f04 -- pm-1 = 0, pm-2 = 29819750, pm-3 = 0 N: ddr fun = 0x0 -- pm = 0x29819750, pm2 = 0x0 N: parameter mcu: v0.5 Mcu Start Work ... get_clocks_value: scpi send command start: 0x10 scpi send command success get clocks = 533 MHZ pll_scp_num = 8 Lmu Freq = 1066Mhz ch = 0 parameter set ch closed! DIMM Don't Probed! ch = 1 the dimm info is from uboot... Dimm_Capacity = 8GB Mcu Channel 1 AES configuration begin... AES bypass end... TZC configuration begin... TZC bypass end... use_0x14 == 0xb0100 ctl_cfg_begin...... pi_cfg_begin...... phy_cfg_begin...... fast mode caslat = 15 wrlat = 14 tinit = 856000 r2r_diffcs_dly = 4 r2w_diffcs_dly = 5 w2r_diffcs_dly = 3 w2w_diffcs_dly = 7 r2w_samecs_dly = 4 w2r_samecs_dly = 0 r2r_samecs_dly = 0 w2w_samecs_dly = 0 ch 1 adapter_alg -- 0-0-0-0-0-0-0 rtt_wr = dis rtt_park = 80ohm ron = 34ohm val_cpudrv = 34 rtt_nom = 48ohm val_cpuodt = 48 vref_dev = 10 vrefsel = 0x45 dq_oe_timing = 0x42 rank_num_decode = 1 set phy_indep_init_mode set pi_dram_init_en set_pi_start & ctl_start...... wait init complete...... init complete done...... wait complete done...... rddqs_lat = 0x2 tdfi_phy_rdlat = 0x1f begin software ntp training... rank_num: 0 phy_write_path_lat_add =-1-1-1-1-1-1-1-1-1 phy_write_path_lat_add = 0 0 0 0 0 0 0 0 0 phy_write_path_lat_add = 1 1 1 1 1 1 1 1 1 phy_write_path_lat_add = 2 2 2 2 2 2 2 2 2 phy_write_path_lat_add = 3 3 3 3 3 3 3 3 3 phy_write_path_lat_add = 4 4 4 4 4 4 4 4 4 rank 0 wdqlvl! r2r_diffcs_dly = 4 r2w_diffcs_dly = 7 w2r_diffcs_dly = 4 w2w_diffcs_dly = 6 r2w_samecs_dly = 5 rank 0 ch 1 training fail
根据您提供的信息,似乎是内存训练过程中出现了错误。错误信息中指出了CH1内存信息不同的问题,以及训练过程中的一些参数和配置。其中,"Mcu Channel 1 AES configuration begin... AES bypass end... TZC configuration begin... TZC bypass end... use_0x14 == 0xb0100 ctl_cfg_begin"等信息表示内存控制器的一些配置和初始化过程。而"rank 0 wdqlvl! r2r_diffcs_dly = 4 r2w_diffcs_dly = 7 w2r_diffcs_dly = 4 w2w_diffcs_dly = 6 r2w_samecs_dly = 5 rank 0 ch 1 training fail"则表示在对CH1的rank0进行写数据时出现了训练失败的情况。
具体的原因可能需要进一步分析,可能与内存硬件、时序参数、内存控制器等方面有关。建议您尝试重新启动或重新插拔内存模块,并检查是否有硬件故障或不良连接的情况。同时,您也可以检查内存访问时序参数和内存控制器的配置是否正确。如果问题仍然存在,建议您查看更详细的错误信息或寻求专业的技术支持。
阅读全文
相关推荐















