python paramiko SFTP文档地址: http://docs.paramiko.org/en/2.4/api/sftp.html
import paramiko

host = "THEHOST.com"                    #hard-coded
port = 22
transport = paramiko.Transport((host, port))

password = "THEPASSWORD"                #hard-coded
username = "THEUSERNAME"                #hard-coded
transport.connect(username = username, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)

import sys
path = './THETARGETDIRECTORY/' + sys.argv[1]    #hard-coded
localpath = sys.argv[1]
sftp.put(localpath, path)

sftp.close()
transport.close()
print 'Upload done.'

python清空文件夹下log文件

#!/usr/bin/python import os import sys files_list = [] def print_files(path): lsdir = os.listdir(path) dirs = [i for i in lsdir if os.path...

阅读全文

python 执行cmd命令并获取pid

process = subprocess.Popen('cmd命令') pid = process.pid print(pid)

阅读全文

适用于python 3+ pymsql 扩展类

适用于python 3+ pymsql 扩展类,包含增删改查 首先要安装pymsql , pip install pymysql document : https://pypi.org/project/PyMySQL/ github :https:/...

阅读全文

1 条评论

欢迎留言