groovy - Groovy:插入文本的字符串列表丢失撇号
问题描述
我想创建一个文本,在其中插入一个 stings 列表 ["aa","bb"]。
def texts = ["aa" , "bb"]
def out = "my list: $texts"
println out
我希望输出为:
我的清单:["aa","bb"]
但我得到的输出是:
我的清单:[aa, bb]
我该如何解决这个问题?
解决方案
The result of texts.toString()
does not include the quotation marks. So you have to create that output yourself:
def out = "my list: ${texts.collect{'"' + it + '"'}}"
推荐阅读
- arrays - 在 O(n) 中对部分排序的数组进行排序
- python - 我不明白关于递归(python)的那部分代码
- android - Android 自动同步和省电模式
- rinsim - RinSim 中可以穿过其他对象的对象
- python - 许多列表列表 - 仅返回第一个索引匹配的列表
- java - Android Studio 中的错误 多个 dex 文件定义 Lcom/google/android/gms/internal/measurement/zzabn;
- scala - db withSession { 隐式会话 => 中涉及的 scala 概念
- php - 验证 ip 和主机名 laravel
- javascript - InstancedBufferGeometry 的 PhongMaterial
- java - 亨德尔边缘案例在寻找 3 点的外心。[JAVA]