Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python ÖÐʹÓÃparamiko¼òµ¥Á¬½Ó

ÔÚparamikoÖÐʹÓÃÓû§ÃûºÍÃÜÂëͨ¹ýsftp´«ÊäÎļþ£¬²»Ê¹ÓÃkeyÎļþ¡£
import getpass
import select
import socket
import traceback
import paramiko
def putfile():
#import interactive
# setup logging
paramiko.util.log_to_file('demo.log')
username = username
hostname = hostname
port = 22
# now connect
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))
except Exception, e:
print '*** Connect failed: ' + str(e)
traceback.print_exc()
sys.exit(1)
t = paramiko.Transport(sock)
try:
t.start_client()
except paramiko.SSHException:
print '*** SSH negotiation failed.'
sys.exit(1)
keys = {}
# check server's host key -- this is important.
key = t.get_remote_server_key()
# get username
t.auth_password(username, password)
sftp = paramiko.SFTPClient.from_transport(t)
# dirlist on remote host
d=datetime.date.today()-datetime.timedelta(1)
sftp.put(localFile,serverFile)
t.close() 
sftp.putÊÇ¿ÉÒÔÖ±½ÓʹÓÃĿ¼ºÍÎļþÃû£¬Èç¹ûÓÐͬÃûÎļþÎļþ½«¸²¸Ç


Ïà¹ØÎĵµ£º

²ËÄñѧPython£¨Ò»£©

   Ϊ³äʵ×Ô¼ºÄÇƽӹµÄ֪ʶ¿â£¬´Ó½ñÌ쿪ʼ£¬Ñ§Ï°PythonÓïÑÔ¡£   Ì«¸ßÉîµÄ×ÊÁÏ¿´²»¶®£¬µ±Á˱¾×î¼òµ¥µÄPython¼òÃ÷½Ì³Ì£¬ÖÐÎÄ°æchm¸ñʽµÄ¡£²»Ëµ·Ï»°ÁË£¬¿ªÊ¼½øÈëPythonµÄÊÀ½ç°É¡£ £¨Ò»£©°²×°Python    дÕâƪÎÄÕÂʱ£¬PythonµÄ×îа汾ÊÇ3.1£¬ÎÒϲ»¶ÓÃ×îеģ¬¾ÍÏÂÁËа汾µÄ¡£Ò»Â·NextÏÂÈ¥£¬ÎÒµÄC ......

Python×Ö·û´®µÄencodeÓëdecode


Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö·û´®×ª» ......

Python ¿½±´¶ÔÏó£¨É±´deepcopyÓëdz¿½±´copy£©

>>> import copy
>>> a = [1,2,3,4,['a','v']]
>>> b = a
>>> b
[1, 2, 3, 4, ['a', 'v']]
>>> c = copy.copy(a)
>>> c
[1, 2, 3, 4, ['a', 'v']]
>>> d = copy.deepcopy(a)
>>> d
[1, 2, 3, 4, ['a', 'v']]
>>> a.append(5) ......

pythonÓ¦ÓÃÁìÓò½éÉÜ

 
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óᣠ
ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó¹¦ÄÜ£º 
Python£¨ÅÉÉ­£©£¬ËüÊÇÒ»¸ö¼òµ¥µÄ¡¢½âÊÍÐ͵ġ¢½»»¥Ê½µÄ¡¢¿ÉÒÆÖ²µÄ¡¢ÃæÏò¶ÔÏóµÄ³¬¸ß¼¶ÓïÑÔ¡£Õâ¾ÍÊǶÔPython ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ