The problem of string substitution in python

    new_file = old_file.replace(" ", "-").replace(""", "").replace("" ", "").replace("(", "").replace(")","").replace(":", "-")

there are a lot of special characters when dealing with folders. Apart from this, is there an elegant way that I think is too ugly?

Mar.08,2022

you can do this:

  str.maketrans  mentioned in the document: 

  • the first two parameters establish an one-to-one mapping
  • the characters of the third parameter are mapped to ''
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54f73-452e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54f73-452e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?