String code required please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dapgy@yahoo.com

    #1

    String code required please

    Does someone have the Python code to pull just the filename and
    extension from the end of an absolute path please.

    Thanks in advance ...

  • SPE - Stani's Python Editor

    #2
    Re: String code required please

    import os
    fileName = os.path.basenam e(absolute)
    base, ext = os.path.splitex t(fileName)

    Stani

    Free python IDE for Windows,Mac & Linux with UML,PyChecker,Debugger,GUI design,Blender & more


    Comment

    • da_hmea98@hotmail.com

      #3
      Re: String code required please

      dapgy@yahoo.com wrote:[color=blue]
      > Does someone have the Python code to pull just the filename and
      > extension from the end of an absolute path please.
      >
      > Thanks in advance ...[/color]

      # Here you go...
      import os.path

      # Example path
      p1 = "C:\\WINDOWS\\s ystem32\\Direct X\\Dinput\\mse. ini"

      # This will return: 'mse.ini'
      os.path.basenam e(p1)

      """
      You can read more about manipulating file paths by reading the Python
      documentation under "6.2 os.path -- Common pathname manipulations".

      DA
      """

      Comment

      Working...