[英]How to add a Quotation mark to a variable in dart
我在 flutter 中聲明了一個變量,我想將它打印為字符串,並在其周圍加上引號,如下所示:
String name = "samuel";
so when I print it out I would get double quotations around it
"Samuel"
我試過
print("'" + name +"'")
print('"' + name + '"')
print("\"" + name + "\"")
但沒有一個工作。 請問,我怎樣才能在飛鏢中實現這一目標?
您可以使用
print('"$name"')
print("'$name'") // prints ' quotes
print('\"$name\"')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.