Aquesta és una revisió antiga del document


Python strings

  • Exact match (equality comparison): ==, !=
  • Partial match: in, not in
  • Forward/backward match: startswith(), endswith()
  • Order comparison: <, ⇐, >, >=
  • Case-insensitive comparison: upper(), lower()
  • Regex: re.search(), re.fullmatch()

/via: https://note.nkmk.me/en/python-str-compare/

  • ljust(), rjust(), center()
  • %15s, %15-s
  • {:15}, {:>15}

/via:https://www.delftstack.com/es/howto/python/python-pad-string-with-spaces/

  • s1+s2
  • »%s %s«%(s1,s2)
  • »-«.join([s1,s2])
  • »{}{}«.format(s1,s2)

/via: https://www.tutorialspoint.com/how-to-concatenate-two-strings-in-python

  • development/python/strings.1675327504.txt.gz
  • Darrera modificació: 02/02/2023 00:45
  • per mate