2024-04-25 12:51:53 发布
网友
我想向文件添加特定扩展名(可能有扩展名,也可能没有扩展名),我尝试了以下代码:
import os thisFile = "/home/username/myfile.txt" base = os.path.splitext(thisFile)[0] os.rename(thisFile, base + ".doc")
还有别的办法吗?你知道吗
嗯,没有理由使用base变量。。。你知道吗
base
os.rename(thisFile, os.path.splitext(thisFile)[0] + ".doc")
但除此之外,我觉得还不错。你知道吗
嗯,没有理由使用
base
变量。。。你知道吗但除此之外,我觉得还不错。你知道吗
相关问题 更多 >
编程相关推荐