S
S
Sacred702018-09-17 15:31:45
Python
Sacred70, 2018-09-17 15:31:45

How to put a filename into a variable via Python3?

Good afternoon. It is required to enter the file name into the variable. For example: there is a video file, I am manipulating it and the modified file must be named: original name + postscript, so I need to drive the name of the source file into a variable, so that later I can use it to name the changed one, the name needs to be saved without extension. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Tikhonov, 2018-09-17
@Sacred70

>>> filename = input("Input filename: ")
Input filename: filename
>>> filename
'filename'

M
mark okolov, 2018-09-17
@okolovmark

from os.path import basename
print(basename("/a/b/c.txt"))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question