7
파이썬에서 rsync 명령을 실행해야합니다. 이것이 가능합니까? 그렇다면 어떻게해야합니까? 의견Python에서 Rsync 실행
는rsync -Ccavz --delete DJStatic [email protected]
답변 I 당신은, 귀하의 경우에는 다음 코드
import subprocess
subprocess.call(["ls", "-l"])
를 사용하여 파이썬에서 하위 프로세스를 호출 할 수 있습니다
from subprocess import call
call(['ls']) - working currently to expand this to rsync, but you get the idea
python http://docs.python.org/2/library/subprocess.html에서 쉘 명령을 실행할 수 있으며, 또한 'fabric'은 많은 comman 쉘 명령 http : //docs.fabfile을 래핑하는 멋진 API를 제공합니다. org/ko/1.4.0/index.html – dm03514
2017 년에는 pure python rsync 라이브러리 :: [pyrsync] (https://github.com/isislovecruft/pyrsync) (wrapper가 아님) – philshem