liudaqi
V2EX  ›  问与答

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

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