我正在使用“to_tcl”函数(自己的代码)将python列表转换为tcl列表。我想迭代Python中的所有列表(第1部分,第2部分。。。Pat 4)并使用函数将其转换为tcl列表(Pat1_tcl,Pat2_tcl,…,Pat4_tcl),但是在Pat%d{count}\u tcl}=to_tcl(Pat%d{count})行中插入数字(count)时出错。如何正确格式化%d个整数部分
count = 0
while count < 5:
Pat{%dcount}_tcl} = to_tcl(Pat{%dcount})
print(Pat{count}_tcl)
count += 1
您可以创建列表列表,然后对其进行迭代:
此示例还将所有转换的tcl列表附加到名为
tcl_lists
的列表中;您可以稍后使用它访问转换后的列表,如tcl_lists[2]
相关问题 更多 >
编程相关推荐