如何在字符串中添加撇号(“)? [英] How to add apostrophe (") to string?
问题描述
我有这个AutoIt脚本:
I have this AutoIt script:
ControlFocus("Open", "", "Edit1")
Sleep(500)
ControlSetText("Open", "", "Edit1", $CmdLine[1])
Sleep(500)
ControlClick("Open", "", "Button1")
它在文件选择窗口中键入文件名.我想在字符串(作为命令行参数发送到脚本的字符串)之前和之后添加"
.
It types a file name inside a file selection window. I want to add "
before and after my string (the string I send as command line argument to my script).
我尝试了ControlSetText("Open", "", "Edit1", $CmdLine[1] & """)
,但这会导致错误:Unterminated string.
.
I tried ControlSetText("Open", "", "Edit1", $CmdLine[1] & """)
but this results into error: Unterminated string.
.
推荐答案
Autoit使用对引号来指示字符串中的单个实例.
Autoit uses pairs quotes to indicate a single instance within a string.
例如""""
(注意,有4个双引号)充当字符串中的单个双引号.
E.g., """"
(notice, there are 4 double quotation marks) acts as a single double-quote within the string.
所以$CmdLine[1] & """"
应该添加一个双引号.
So $CmdLine[1] & """"
should add a single double-quote.
请参阅AutoIt的文档. https://www.autoitscript.com/autoit3/docs/intro/lang_datatypes. htm 中有关于字符串的部分.
See AutoIt's documentation. https://www.autoitscript.com/autoit3/docs/intro/lang_datatypes.htm has a section on strings.
这篇关于如何在字符串中添加撇号(“)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!