我正在编写Tera术语宏,我需要分配一个包含'和"的字符串变量。我看过各种教程,但找不到如何做到这一点,所以希望它是存在的。
这些字符串变量不能工作:
hello = "command1 argument1 "foo/hello/world.txt""
world = 'command2 argument2 'bar/hello/world.txt''给出的语法错误:

通过实验,我发现,我可以混合和匹配单引号和双引号,以便允许一个或另一个,但不能两者兼而有之。
这些字符串变量可以工作:
foo = "command1 argumen1t 'foo/hello/world.txt'"
bar = 'command2 argument2 "bar/hello/world.txt"'发布于 2014-08-26 17:46:59
我不确定字符串是否有转义字符(我搜索了字符串,但没有在上面找到任何内容),但是我找到了解决这个问题的方法。我不是说这是正确的方法,但至少它可能适合你的情况。
为了发送引号,我使用了斯登 ( 发送函数中的实际文档)的ASCII值特性。
FILE1='foo/hello/world.txt'
FILE2='bar/hello/world.txt'
sendln 'command1 argument1 ' 34 FILE1 34
sendln 'command2 argument2 ' 39 FILE2 39对上述宏进行测试后,将生成以下输入终端的宏
command1 argument1 "foo/hello/world.txt"
command2 argument2 'bar/hello/world.txt'https://stackoverflow.com/questions/25450692
复制相似问题