繁体   English   中英

Netlogo 中是否有多行字符串语法?

[英]Is there a multi-line string syntax in Netlogo?

在 Python 中,有一种方法可以将长的多行文本存储到变量中,如下所示:

    a_string = """
          This is a very long string
          that spans multiple lines
          and I do not need to worry about
          line breaks
    """

我的问题:在NetLogo中是否有类似的东西,我可以将一段文本装入特殊字符并存储到一个变量中? 任何替代方法(例如字符串连接)也可以使用,如下所示:

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."
           

到目前为止,我找不到任何类似前一个例子的东西,也没有真正搜索过后者,因为前者是我的偏好,但我会很感激任何其他选择。

原语这个word应该可以做你想做的事。 只需确保用括号将其括起来即可处理多个值。 例子:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM