[英]Is there a multi-line string syntax in Netlogo?
In Python there is a way to store long, multi-line text into a variable like so:在 Python 中,有一种方法可以将长的多行文本存储到变量中,如下所示:
a_string = """
This is a very long string
that spans multiple lines
and I do not need to worry about
line breaks
"""
My question: Is there a similar thing in NetLogo where I can just encase a block of text into special characters and store into a variable?我的问题:在NetLogo中是否有类似的东西,我可以将一段文本装入特殊字符并存储到一个变量中? Any alternative ways, such as string concatenation will work too, like so:任何替代方法(例如字符串连接)也可以使用,如下所示:
a_string = "This is a very long string"
+ "and I might need to use some regexes"
+ "to get it into this format\n"
+ "as long as it's possible to do so."
So far I could not find anything like the former example, have not really searched for the latter as the former is my preference, but would appreciate any other alternatives.到目前为止,我找不到任何类似前一个例子的东西,也没有真正搜索过后者,因为前者是我的偏好,但我会很感激任何其他选择。
The word
primitive should be able to do what you want. 原语这个word
应该可以做你想做的事。 Just make sure to surround it with parentheses to handle multiple values.只需确保用括号将其括起来即可处理多个值。 Example:例子:
to set-a-string
let a_string (word "This is a very long string"
"and I might need to use some regexes"
"to get it into this format\n"
"as long as it's possible to do so.")
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.