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

¹ØÓÚPythonµÄjoin£¨£©·½·¨ÎÊÌâ

´úÂëÈçÏ£º
import os
import time

source = [r'e:\python',r'e:\temp']
#print(source)
print('Ô´£º')
for spath in source:
    print(spath)
target_dir = r'e:\bak'
print('\nÄ¿µÄµØ£º')
print(target_dir)
target = time.strftime('%Y%m%d%H%M%S') + '.rar'
zip_command = 'rar a %s\%s %s' % (target_dir,target,' '.join(source))

if os.system(zip_command) == 0:
    print('Successful backup to',target)
else:
    print('Backup FAILED')

ÎÊÌ⣺
Çë½Ìһϣ¬' '.join(source)µÄ×÷ÓÃÊǽ«ÁбísourceÖеÄÏîĿת»»Îª×Ö·û´®£¬ÄÇôΪʲôҪÔÚÕâ¸ö·½·¨Ç°¼ÓÉÏ' '.£¿ÕâÊÇʲôÓÃ;£¿ÎªÊ²Ã´²»ÄÜÖ±½ÓʹÓÃjoin(source)£¿ÎÒÊdzõѧÕߣ¬Âé·³¸÷λ²»Áߴͽ̣¬Ð»Ð»£¡
ÒòΪËûÊÇstrµÄÒ»¸ö·½·¨£¬²»ÊÇͨÓú¯Êý¡£¼´Ê¹ÓиöͨÓú¯ÊýÒ²Ó¦¸ÃÏñjoin(source, sep)¶à¸ö·Ö¸ô·û²ÎÊý²Å»áÏ൱...

¶Ôà¸, strµÄÒ»¸ö·½·¨

>>> s=''
>>> dir(s)
.......'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', ...

ÄãÏëÖ±½ÓÓÃjoinÒ²¿ÉÒԵİ¡£¬Ã»ÎÊÌ⣺

import string
string.join(["aaaa", "bbb"])

»òÕߣº

from string


Ïà¹ØÎÊ´ð£º

IIS 7 python 2.6 cgi ÎļþÉÏ´«ÎÊÌâ

ÎÒÿ´ÎÉÏ´«µÄÎļþ¶Áµ½µÄÊý¾Ý¶¼²»ÕýÈ·¡£2M µÄͼƬ¶ÁµÃ10¶àK ¡£¡£ÄÄλ´óÏÀ¿ÉÒÔ°ï°ïÎÒ°¡¡£
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......

¶®pythonµÄjava¸ßÊÖÇë½Ì - Java / Java SE

ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......

python ÖÐÒ»¸öÒÉ»ó

return func Óëreturn func()
ÓÐʲô²»Í¬µÄ£¿
return func·µ»ØµÄÊÇÒ»¸öº¯Êý¶ÔÏó£¬
return func()·µ»ØµÄÊÇfunc()º¯ÊýµÄ·µ»Ø½á¹û¡£

Â¥ÉÏÕý½â

Ò»¸öÊÇ·µ»Ø±äÁ¿ Ò»¸öÊÇ·µ»ØµÄʱºò ÔÙµ÷ÓÃÒ»ÏÂfuncº¯Êý
ÎÒ¾õµÃÊÇ ......

¡¾ÇóÖú¡¿¹ØÓÚpythonÖÐ×Ö½ÚÊý×éת»»³É×Ö·û´®

ÓÉÓÚÊdzõѧ£¬ÔÚЩÇë½Ì´ó¼Ò¡£

Python code:

from urllib import request
import struct
class csdn:
def __init__(self):
print ('Hello,this is a init')
def getContent(self,url) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ