V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
liudaqi
V2EX  ›  问与答

示例符号用 [, 有什么特别约定吗? 像这样的 str.endswith(suffix[, start[, end]])

  •  
  •   liudaqi · 2019-05-18 10:11:29 +08:00 · 1666 次点击
    这是一个创建于 1795 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看到好多都是像这样的

    str.endswith(suffix[, start[, end]])
    

    是约定俗成的吗?还是随便都可以?

    5 条回复    2019-05-18 13:30:54 +08:00
    Eleflea
        1
    Eleflea  
       2019-05-18 10:16:59 +08:00
    [xxx]表示 xxx 是可选的。
    airyland
        2
    airyland  
       2019-05-18 10:17:16 +08:00
    约定用来表示可选参数
    dcatfly
        3
    dcatfly  
       2019-05-18 11:37:38 +08:00
    额 括号是个整体,不应该分开来看。
    []在楼主举例中表示可选参数,因为参数直接需要分隔,所以凑巧出现了`[,` 。
    lrz0lrz
        4
    lrz0lrz  
       2019-05-18 12:31:17 +08:00
    这时一种约定俗成的表示法,好像并没有明确的规范。
    可以参考 http://man7.org/linux/man-pages/man7/man-pages.7.html 的 DESCRIPTION -> Sections within a manual page -> SYNOPSIS 这一段或者
    https://unix.stackexchange.com/questions/17833/understand-synopsis-in-manpage。
    howe670
        5
    howe670  
       2019-05-18 13:30:54 +08:00
    接楼上,补充下,还可以看这个,讲了尖括号、中括号等等常见的符号约定。
    http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1096 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:38 · PVG 02:38 · LAX 11:38 · JFK 14:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.