Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私の変数は次のような名前です:
var1 = '/home/name/file.txt'
変数でファイルの名前を取得する方法は?
次のような変数が必要です。
var1 = 'file.txt'
>>> import os >>> os.path.basename('/home/name/file.txt') 'file.txt'