我的TCL字符串有问题
set WORD 128
set CELL_NAME "MCELL_$WORD\x1"
# real: MCELL_128.. (.. is 2 special characters that I can't paste here)
# expected: "MCELL_128x1"
如何按预期格式化字符串?
答案 0 :(得分:2)
set CELL_NAME "MCELL_${WORD}x1"
为您提供预期的输出。
其他可能性:
set CELL_NAME "MCELL_[set WORD]x1"
set CELL_NAME [format "MCELL_%dx1" $WORD]
文档: format, set, Summary of Tcl language syntax,特别是[8]项。