Long paths in Python on Windows

前端 未结 3 440
星月不相逢
星月不相逢 2020-11-30 07:40

I have a problem when programming in Python running under Windows. I need to work with file paths, that are longer than 256 or whatsathelimit characters. Now, I\'ve read ba

3条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 08:22

    py 3.8.2

    # Fix long path access:
    import ntpath
    ntpath.realpath = ntpath.abspath
    # Fix long path access.
    

    In my case, this solved the problem of running a script from a long path. (https://developers.google.com/drive/api/v3/quickstart/python) But this is not a universal fix. It looks like the ntpath.realpath implementation has problems. This code replaced it with a dummy.

提交回复
热议问题