问题描述
我想将 for main_str in main_str_ls:
main_str = main_str.strip()
for substr in substr_ls:
substr = substr.strip()
if is_subsequence(substr,main_str):
**do stuff**
重命名为 Product :
我的代码:
Motherboard :
输出:
Get-WmiObject win32_baseboard | Format-List Product,Manufacturer
解决方法
您可以使用计算的属性表达式在 PowerShell 中重命名属性:
Get-WmiObject win32_baseboard | Format-List @{Name='MotherBoard';Expression='Product'},Manufacturer
在这种情况下,我们告诉 Format-List
计算一个新属性 Motherboard
,它应该从现有的 Product
属性中获取其值