Python scp copy file with spaces in filename

后端 未结 3 1700
离开以前
离开以前 2021-01-26 04:53

I\'m trying to copy files in local network with scp. It\'s working well with filenames without spaces, but it crash with. I\'ve tried to replace \" \" with \"\\ \" as this exemp

3条回答
  •  自闭症患者
    2021-01-26 05:35

    Use subprocess module and/or shlex.split():

    import subprocess
    subprocess.call(['scp', file_pc, file_pi])
    

    and you don't need to worry about escaping or quoting anything

提交回复
热议问题