whitespaces in the path of windows filepath

后端 未结 4 946
闹比i
闹比i 2020-11-30 04:13

I am working on file operations using python.

I have a filepath as :

filepath = \"E:/ABC/SEM 2/testfiles/all.txt\"

when I am op

4条回答
  •  渐次进展
    2020-11-30 04:26

    (WINDOWS - AWS solution)
    Solved for windows by putting tripple quotes around files and paths.
    Benefits:
    1) Prevents excludes that quietly were getting ignored.
    2) Files/folders with spaces in them, will no longer kick errors.

        aws_command = 'aws s3 sync """D:/""" """s3://mybucket/my folder/"  --exclude """*RECYCLE.BIN/*""" --exclude """*.cab""" --exclude """System Volume Information/*""" '
    
        r = subprocess.run(f"powershell.exe {aws_command}", shell=True, capture_output=True, text=True)
    

提交回复
热议问题