liudaqi
V2EX  ›  问与答

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

  •  
  •   liudaqi · May 18, 2019 · 2573 views
    This topic created in 2552 days ago, the information mentioned may be changed or developed.

    看到好多都是像这样的

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

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

    5 replies    2019-05-18 13:30:54 +08:00
    Eleflea
        1
    Eleflea  
       May 18, 2019
    [xxx]表示 xxx 是可选的。
    airyland
        2
    airyland  
       May 18, 2019
    约定用来表示可选参数
    dcatfly
        3
    dcatfly  
       May 18, 2019
    额 括号是个整体,不应该分开来看。
    []在楼主举例中表示可选参数,因为参数直接需要分隔,所以凑巧出现了`[,` 。
    lrz0lrz
        4
    lrz0lrz  
       May 18, 2019
    这时一种约定俗成的表示法,好像并没有明确的规范。
    可以参考 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。
    howard777
        5
    howard777  
       May 18, 2019
    接楼上,补充下,还可以看这个,讲了尖括号、中括号等等常见的符号约定。
    http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3197 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 14:30 · PVG 22:30 · LAX 07:30 · JFK 10:30
    ♥ Do have faith in what you're doing.