标签: python string python-3.x variables
是否可以操纵变量,例如: file = "/Python/work.txt" 只是列出work.txt,没有/ Python?排除" /"?
file = "/Python/work.txt"
谢谢
答案 0 :(得分:1)
当然!只需这样做:
file = "/Python/work.txt" excluded = file.split("/")[-1]
这将在排除变量中返回“work.txt”。