如何将撇号(“)添加到字符串? [英] How to add apostrophe (") to string?

查看:32
本文介绍了如何将撇号(“)添加到字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 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] & """) 但这会导致错误:未终止的字符串.代码>.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆