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

Python±Ê¼Ç£¨9£©

PythonÖеÄÎļþ²Ù×÷ÒÔ¼°ÊäÈëÊä³ö
ÎÒÃÇ¿ÉÒÔ·Ö±ðʹÓÃraw_inputºÍprintÓï¾äÀ´Íê³ÉÕâЩ¹¦ÄÜ¡£¶ÔÓÚÊä³ö£¬ÄãÒ²¿ÉÒÔʹÓöàÖÖ¶àÑùµÄstr£¨×Ö·û´®£©Àà¡£ÀýÈ磬ÄãÄܹ»Ê¹ÓÃrjust·½·¨À´µÃµ½Ò»¸ö°´Ò»¶¨¿í¶ÈÓÒ¶ÔÆëµÄ×Ö·û´®¡£ÀûÓÃhelp(str)»ñµÃ¸ü¶àÏêÇé¡£
 
 
ÁíÒ»¸ö³£ÓõÄÊäÈë/Êä³öÀàÐÍÊÇ´¦ÀíÎļþ¡£´´½¨¡¢¶ÁºÍдÎļþµÄÄÜÁ¦ÊÇÐí¶à³ÌÐòËù±ØÐèµÄ£¬ÎÒÃǽ«»áÔÚÕâÕÂ̽Ë÷ÈçºÎʵÏÖÕâЩ¹¦ÄÜ¡£
Ò».ʹÓÃÎļþ
Äã¿ÉÒÔͨ¹ý´´½¨Ò»¸öfileÀàµÄ¶ÔÏóÀ´´ò¿ªÒ»¸öÎļþ£¬·Ö±ðʹÓÃfileÀàµÄread¡¢readline»òwrite·½·¨À´Ç¡µ±µØ¶ÁдÎļþ¡£¶ÔÎļþµÄ¶ÁдÄÜÁ¦ÒÀÀµÓÚÄãÔÚ´ò¿ªÎļþʱָ¶¨µÄģʽ¡£×îºó£¬µ±ÄãÍê³É¶ÔÎļþµÄ²Ù×÷µÄʱºò£¬Äãµ÷ÓÃclose·½·¨À´¸æËßPythonÎÒÃÇÍê³ÉÁ˶ÔÎļþµÄʹÓã¬ÔÚ¸÷·½Ã棬ÓëC/C++ÀàËÆ¡£
#!/usr/bin/python
# Filename: using_file.py
poem = '''\
Programming is fun
When the work is done
if you wanna make your work also fun:
use Python!
'''
f = file('poem.txt', 'w') # open for 'w'riting
f.write(poem) # write text to file
f.close() # close the file
f = file('poem.txt')
# if no mode is specified, 'r'ead mode is assumed by default
while True:
line = f.readline()
if len(line) == 0: # Zero length indicates EOF
break
print line,
# Notice comma to avoid automatic newline added by Python
f.close() # close the file

Êä³öΪ£º
$ python using_file.py
Programming is fun
When the work is done
if you wanna make your work also fun:
use Python!

ģʽ¿ÉÒÔΪ¶Áģʽ£¨'r'£©¡¢Ð´Ä£Ê½£¨'w'£©»ò×·¼Óģʽ£¨'a'£©¡£ÏêϸÇé¿ö¿É¼ûhelp(file)¡£
¶þ.´æ´¢Æ÷
PythonÌṩһ¸ö±ê×¼µÄÄ£¿é£¬³ÆÎªpickle¡£Ê¹ÓÃËüÄã¿ÉÒÔÔÚÒ»¸öÎļþÖд¢´æÈκÎPython¶ÔÏó£¬Ö®ºóÄãÓÖ¿ÉÒÔ°ÑËüÍêÕûÎÞȱµØÈ¡³öÀ´¡£Õâ±»³ÆÎª³Ö¾ÃµØ´¢´æ¶ÔÏó¡£
»¹ÓÐÁíÒ»¸öÄ£¿é³ÆÎªcPickle£¬ËüµÄ¹¦ÄܺÍpickleÄ£¿éÍêÈ«Ïàͬ£¬Ö»²»¹ýËüÊÇÓÃCÓïÑÔ±àдµÄ£¬Òò´ËÒª¿ìµÃ¶à£¨±Èpickle¿ì1000±¶£©¡£Äã¿ÉÒÔʹÓÃËüÃÇÖеÄÈÎÒ»¸ö£¬¶øÎÒÃÇÔÚÕâÀォʹÓÃcPickleÄ£¿é¡£¼Çס£¬ÎÒÃǰÑÕâÁ½¸öÄ£¿é¶¼¼ò³ÆÎªpickleÄ£¿é¡£
ÀýÈç:
#!/usr/bin/python
# Filename: pickling.py
import cPickle as p
#import pickle as p
shoplistfile = 'shoplist.data'
# the name of the file where we will store the object
shoplist = ['a


Ïà¹ØÎĵµ£º

¿ª·¢PythonÓÃʲô¹¤¾ßºÃ£¿

    ¹¤ÓûÉÆÆäʱØÏÈÀûÆäÆ÷£¡
    ¿ª·¢PythonÓÃʲô¹¤¾ßºÃÄØ£¿Æäʵ¸ÕѧPythonµÄ»°£¬Ê¹ÓÃIDLE¾Í¹»ÁË£¬ËäÈ»µ÷ÊÔ²»ÊÇÌØ±ð·½±ã£¬µ«ÊǶÔÓÚ³õѧÒѾ­¹»ÁË£¬¿ÉÒÔʹÓÃPrint½øÐмòµ¥µÄµ÷ÊÔ£¬²»½¨ÒéʹÓüÇʱ¾½øÐпª·¢£¬²»ÖªµÀµÄÈÏΪÄãºÜÅ££¬ÖªµÀµÄ……ÕâÊÇ×Ô¼º¸ø×Ô¼ºÕÒ×ïÊÜ£¬ÓÃEditplusÃ²Ë ......

(ת) pythonÓ¦ÓÃÁìÓò½éÉÜ

#---------------------תתתתתתתתתתתתתתתתתתתתתתת-------------------------------------------#
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊÜºÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨ÌØµã£¬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
 
¡¡¡¡ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó ......

ÓÃCÓïÑÔÀ©Õ¹PythonµÄ¹¦ÄÜ

µ±½ñÓÐÐí¶àÃâ·ÑµÄ RDBMS£¨Relational Database Management
System£¬¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳ£©£¬ÆäÖÐһЩÊÇ¿ª·ÅÔ´ÂëÈí¼þ£¬ÁíһЩÊÇÉÌÒµ³§ÉÌÌṩµÄÃâ·Ñ²úÆ·¡£Èç¹ûÄúÕýÔÚʹÓà C/C++¡¢Java™¡¢.NET
»ò PHP
¿ª·¢Ó¦ÓóÌÐò£¬ÏëѰÕÒÒ»ÖÖ¿É¿¿µÄÊý¾Ý·þÎñÆ÷£¬Ï£ÍûËüÖ§³ÖÏȽøµÄ¼¼Êõ¡¢¾ßÓв»¶ÏÀ©´óµÄ¿ª·¢ÈËÔ±ÉçÇø²¢ÒѾ­²¿ÊðÔÚÐí¶à¹Ø¼ ......

pythonÖеÄÁбíÅÅÐò²Ù×÷

 
 
 
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ