我无法在 tcl 中连接具有新行的字符串。新行将被忽略。有办法克服这个问题吗?
% set pst_data "Power states :-\n"
Power states :-
% set pst_data [concat $pst_data "vcc1\t 1 0 1\n"]
Power states :- vcc1 1 0 1
% set pst_data [concat $pst_data "vcc2\t 2 2 0\n"]
Power states :- vcc1 1 0 1 vcc2 2 2 0
%
我希望输出每次都以单独的新行出现
最佳答案
它在 manual 中提到了它:
This command joins each of its arguments together with spaces after trimming leading and trailing white-space from each of them.
您可以尝试使用 append
相反:
% set pst_data "Power states :-\n"
Power states :-
% append pst_data "vcc1\t 1 0 1\n"
Power states :-
vcc1 1 0 1
% append pst_data "vcc1\t 1 0 1\n"
Power states :-
vcc1 1 0 1
vcc1 1 0 1
%
关于tcl - 在 Tcl 中用换行符连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65948651/