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

PythonÎļþµÄ¶Áд

Ïà±Èjava¶øÑÔ£¬PythonÓü¸ÐдúÂë¾Í¿ÉÒÔ´úÌæjavaÊ®À´ÐеĴúÂ룬ÕæµÄ·Ç³£²»´í
'''
Created on 2009-9-2
@author: jiangqh
'''
# file create and write
context = '''hello world
hello china '''
f = file("hello.txt",'w')
f.write(context)
f.close()
Îļþ´´½¨
#use readline() read file
f = open("hello.txt")
while True:
line = f.readline()
if line:
print line
else :
break
f.close()
Ò»ÐÐÒ»ÐеĶÁÈ¡
# read more lines
f = file("hello.txt")
lines = f.readlines()
for line in lines:
print line
¶àÐжÁÈ¡
Ò»´ÎÐÔÈ«¶Á³öÎļþÀïµÄÄÚÈÝ
'''
Created on 2009-9-2
@author: jiangqh
'''
f = open("hello.txt")
context = f.read()
print context
f = open("hello.txt")
context = f.read(5) #¶ÁÈ¡Ç°Îå×Ö½Ú
print context
print f.tell() #»ñµÃµ±Ç°Ö¸ÕëµÄλÖÃ
context = f.read(5) #¼ÌÐøµ±Ç°¶ÁÈ¡Îåλ
print context
print f.tell() #»ñµÃµ±Ç°Ö¸ÕëµÄλÖÃ
f.close()


Ïà¹ØÎĵµ£º

ÔÚpythonÖÐʹÓÃdllµ¼³öº¯Êý

×î½üÔÚѧϰpy£¬Êµ¼ùÊÇ£ºÐ£ÑéÖ¸¶¨ÎļþÊÇ·ñ´òÉÏÊý×ÖÇ©Ãû~pythonµÄ±ê×¼¿âÖÐûÓÐÌṩÕâÀຯÊý£¬Í¬Ê±ÔÚÍøÉÏËÑÁËÒ»ÏÂҲûÓÐÕÒµ½µÚÈý·½µÄ°üÓÐÌṩ£¬×îºóÕÒµ½ÁË¿ÉÒÔʹÓÃCrypt32.dllµÄµ¼³öº¯ÊýCryptQueryObject()¡£
Ê×ÏÈÎÒÏ£Íûpywin32µÄ°üÖÐ×îºÃÒÑ·â×°ÕâÑùµÄapi£¬½á¹û·¢ÏÖûÓÐ-_-!¡£ÓÚÊDz»µÃ²»×Ô¼º¶¯ÊÖ~pyÖе÷ÓÃdllµÄµ¼³öº¯Êý·½·¨±È ......

PythonµÄASCII, GB2312, Unicode , UTF 8

PythonµÄASCII, GB2312, Unicode , UTF-8
ASCII ÊÇÒ»ÖÖ×Ö·û¼¯,°üÀ¨´óСдµÄÓ¢ÎÄ×Öĸ¡¢Êý×Ö¡¢¿ØÖÆ×Ö·ûµÈ£¬ËüÓÃÒ»¸ö×Ö½Ú±íʾ£¬·¶Î§ÊÇ 0-127 Unicode·ÖΪUTF-8ºÍUTF-16¡£
UTF-8±ä³¤¶ÈµÄ£¬×î¶à 6 ¸ö×Ö½Ú£¬Ð¡ÓÚ 127 µÄ×Ö·ûÓÃÒ»¸ö×Ö½Ú±íʾ£¬Óë ASCII ×Ö·û¼¯µÄ½á¹ûÒ»Ñù£¬ASCII ±àÂëϵÄÓ¢ÓïÎı¾²»ÐèÒªÐ޸ľͿÉÒÔµ±×÷ UTF-8 ±àÂë ......

Pythonѧϰ±Ê¼Ç Îļþ¶Áд

PythonÖÐÎļþ²Ù×÷¿ÉÒÔͨ¹ýopenº¯Êý£¬ÕâµÄÈ·ºÜÏñCÓïÑÔÖеÄfopen¡£Í¨¹ýopenº¯Êý»ñÈ¡Ò»¸öfile object£¬È»ºóµ÷ÓÃread()£¬write()µÈ·½·¨¶ÔÎļþ½øÐжÁд²Ù×÷¡£
1.open
ʹÓÃopen´ò¿ªÎļþºóÒ»¶¨Òª¼ÇµÃµ÷ÓÃÎļþ¶ÔÏóµÄclose()·½·¨¡£±ÈÈç¿ÉÒÔÓÃtry/finallyÓï¾äÀ´È·±£×îºóÄܹرÕÎļþ¡£
file_object = open('thefile.txt') ......

PythonÖ´ÐÐϵͳÃüÁîµÄ·½·¨

PythonÖÐÖ´ÐÐϵͳÃüÁî³£¼û·½·¨ÓÐÁ½ÖÖ£º
Á½Õß¾ùÐè import os
(1) os.system
# ½ö½öÔÚÒ»¸ö×ÓÖÕ¶ËÔËÐÐϵͳÃüÁ¶ø²»ÄÜ»ñÈ¡ÃüÁîÖ´ÐкóµÄ·µ»ØÐÅÏ¢
system(command) -> exit_status   
Execute the command (a string) in a subshell. 
# Èç¹ûÔÙÃüÁîÐÐÏÂÖ´ÐУ¬½á¹ûÖ±½Ó´òÓ¡³öÀ´
>>> os. ......

pythonϵÄweb¿ª·¢¿ò¼Ü Django,½¨Á¢Ä£ÐÍ

Òª´´½¨ÄãµÄapp£¨½«djangoÅäÖõ½»·¾³±äÁ¿Ï£©
python manage.py startapp polls
ËüÃǽ«»á´´½¨Ò»¸öpollsÎļþ¼Ð£¬ÀïÃæµÄÄÚÈÝÊÇ£º
¡¡¡¡polls/
¡¡¡¡¡¡¡¡__init__.py
¡¡¡¡¡¡¡¡models.py
¡¡¡¡¡¡¡¡views.py
Õâ¸öĿ¼½á¹¹¾ÍÊÇappÓ¦ÓóÌÐò¡£
±àдÊý¾Ý¿âWebÓ¦ÓóÌÐòµÄµÚÒ»²½ÊǶ¨ÒåÄãµÄÄ£ÐͲ㗗»ù±¾ÉϾÍÊÇÄãµÄÊý¾Ý¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ