相关疑难解决方法(0)

Windows中断了Python长文件名支持

我编写Python脚本来复制文件; 不幸的是它因为文件名太长(> 256)而一直失败.无论如何要处理这个问题?

我正在使用Python 2.5.4和Windows XP.

干杯,

python windows python-2.x

7
推荐指数
3
解决办法
5338
查看次数

如何从Windows上的python获取长文件系统路径

这给我一个短路径(DOS约定)(在Windows上):

import tempfile
tempDir = tempfile.mkdtemp()
print tempDir

Output >>> c:\users\admini~1\appdata\local\temp\tmpf76unv
Run Code Online (Sandbox Code Playgroud)

请注意admini~1.

如何将其转换为完整路径?例如C:\ users\administrator\appdata ...

python windows path

7
推荐指数
2
解决办法
2784
查看次数

路径名太久无法打开?

这是执行的截图:

在此输入图像描述

如您所见,错误显示目录"JSONFiles/Apartment/Rent/dubizzleabudhabiproperty"不存在.

但是看看我的文件,请:

在此输入图像描述

文件夹肯定在那里.

更新2

代码

self.file = open("JSONFiles/"+ item["category"]+"/" + item["action"]+"/"+ item['source']+"/"+fileName + '.json', 'wb') # Create a new JSON file with the name = fileName parameter
        line = json.dumps(dict(item)) # Change the item to a JSON format in one line
        self.file.write(line) # Write the item to the file
Run Code Online (Sandbox Code Playgroud)

UPDATE

当我将文件名更改为较小的文件名时,它可以正常工作,因此问题在于路径的长度.请问是什么解决方案?

python windows python-2.7

5
推荐指数
3
解决办法
6894
查看次数

标签 统计

python ×3

windows ×3

path ×1

python-2.7 ×1

python-2.x ×1