Pythonѧϰ±Ê¼Ç ¸ß¼¶Ö÷Ìâ
1.ÁбíµÄµÝ¹é---ÓÃÓÚÊä³öÁбí×Ö·û´®ÖеÄÿ¸öÔªËØ >>> def printList(L):
#Èç¹ûΪ¿Õ£¬Ôòʲô¶¼²»×ö
if not L:
return
#Èç¹ûÊÇÁ´±í£¬Ôò¶ÔµÚÒ»¸öÔªËص÷ÓÃprintListº¯Êý
if type(L[0])==type([]):
printList(L[0])
else:#Èç¹û²»ÊÇÁ´±í£¬½öÊä³öÔªËؼ´¿É
print L[0]
#´¦ÀíLµÄÆäËû²¿·Ö
printList(L[1:]) >>> aList=['a',['b','c',['d','e']],'f',[],'g']
>>> printList(aList)
a
b
c
d
e
f
g
>>> ÓÉÓÚÉÏÀýÖÐÊÇÁбíµÄǶÌ×£¬ËùÒÔÎÒÃDZØÐë²âÊÔÊ×ÏîÊÇ·ñΪһ¸öÁÐ±í£¬Èç¹ûÊÇ£¬ÔòµÝ¹éµ÷ÓÃprintList()º¯Êý£¬Èç¹û²»ÊÇ£¬ÄÇÎÒÃǾͼòµ¥µØ´òÓ¡Ëü¡£´¦ÀíÍêÊ×Ïîºó£¬ÎÒÃǽ«¼ÌÐø´¦ÀíÁбíµÄÆäËû¸÷Ïî¡£ ÔÚ´óÐÍÊý¾Ý½á¹¹ÖУ¬µÝ¹é»áºÄ¾¡Äڴ棬Òò´Ë£¬Èç¹ûÄãµÄÄÚ´æ±È½ÏС£¬»òÕßÏë´¦ÀíºÜ´óµÄÊý¾Ý½á¹¹£¬ÄÇôʹÓøü¸´Ôӵij£¹æ´úÂë¿ÉÄܸü°²È«Ð©¡£ 2.PythonÓÐÈýÖÖÃû×ֿռ䣺 ¾Ö²¿---ÔÚÀ࣬ģ¿é»ò·½·¨Öж¨ÒåµÄÃû×Ö Ä£¿é---ÔÚÎļþÖж¨ÒåµÄÃû×Ö ÄÚÖÃ---python×ÔÉí¶¨ÒåµÄÃû×Ö Èç¹ûÒª·ÃÎÊÄ£¿éÃû×ֿռ䣬ʹÓÃimport 3.ʼþÇý¶¯±à³Ì£ºÃæÏòÅú´¦ÀíµÄ³ÌÐòÁ÷³ÌÊÇ---Æô¶¯³ÌÐò£¬´¦ÀíÊÂÇ飬ȻºóÖÕÖ¹³ÌÐò£»¶øʼþÇý¶¯³ÌÐòÁ÷³ÌÊÇ---Ö»ÓÐͨ¹ýʼþ´¥·¢£¬³ÌÐò²ÅÆô¶¯³ÌÐò£¬µÈ´ýʼþ£¬È»ºóÓÉʼþ֪ͨËüÖÕÖ¹ ±àдʼþÇý¶¯³ÌÐòÓÐÁ½ÖÖ·½Ê½£ºÒ»ÊÇÄ£ÄâÒ»¸öʼþ»·¾³£»¶þÊÇ´´½¨Ò»¸ö¼òµ¥µÄGUI³ÌÐò£¬¸Ã³ÌÐò¿ÉÀûÓòÙ×÷ϵͳºÍ»·¾³À´Éú³Éʼþ¡£ ʼþ²¶»ñºÍ´¦ÀíµÄ¶ÀÁ¢ÐÔÊÇʼþÇý¶¯±à³ÌµÄ¹Ø¼üÌØÐÔ¡£
Ïà¹ØÎĵµ£º
ÎÒÃǾ³£»á²ÉÓÃÉú²úÕß/Ïû·ÑÕß¹ØϵµÄÁ½¸öÏß³ÌÀ´´¦ÀíÒ»¸ö¹²Ïí»º³åÇøµÄÊý¾Ý¡£ÀýÈçÒ»¸öÉú²úÕßÏ߳̽ÓÊÜÓû§Êý¾Ý·ÅÈëÒ»¸ö¹²Ïí»º³åÇøÀµÈ´ýÒ»¸öÏû·ÑÕßÏß
³Ì¶ÔÊý¾ÝÈ¡³ö´¦Àí¡£µ«ÊÇÈç¹û»º³åÇøµÄ̫С¶øÉú²úÕߺÍÏû·ÑÕßÁ½¸öÒì²½Ï̵߳ÄËٶȲ»Í¬Ê±£¬ÈÝÒ׳öÏÖÒ»¸öÏ̵߳ȴýÁíÒ»¸öÇé¿ö¡£ÎªÁ˾¡¿ÉÄܵÄËõ¶Ì¹²Ïí×ÊÔ´²¢ÒÔÏàͬ
Ëٶȹ¤×÷µÄ¸÷Ïß³ ......
ÏÈ˵python
pythonµÄrandomÄ£¿éÌṩÁ˶à¸öαËæ»úÊý·¢ÉúÆ÷£¬Ä¬È϶¼ÊÇÓõ±Ç°Ê±¼ä´ÁΪËæ»úÊýÖÖ×Ó¡£
ÏÂÃæÊǸÃÄ£¿é¼¸¸ö×î³£Óõĺ¯Êý
random() Return the next random floating point number in the range [0.0, 1.0).
randint(a,b) Return a random integer N such that a <=
N <= b
randrange([star ......
ÎҵĻ·¾³ÊÇ£ºLinux version 2.4.21-4.EL
(bhcompile@daffy.perf.redhat.com) (gcc version 3.2.3 20030502 (Red Hat
Linux 3.2.3-20)) #1 Fri Oct 3 18:13:58 EDT 2003 + Python2.6.4
±¾ÎĽáºÏÎÒ°²×°Ê±ºòµÄÎÊÌ⣬×ܽá¶ø³É
Óû§Ä¿Â¼Èç/home/liuguanyu/ , ±£Ö¤Óû§ÓÐrootȨÏÞ
1£¬¿´¿´ÓÐûÓа²×°
&nbs ......
# coding=gb2312
# ÓÃÖÐÎÄ×¢ÊÍÇ°Îñ±Ø¼ÓÉϵÚÒ»ÐÐ
# ÇóÄ£ÔËËã·û£¬ºÍCÓïÑÔÒ»Ñù
print 10%9
# ÕûÊýÏà³ýÈÔÈ»ÊÇÕûÊý
print 5/2
# 2ºó¼ÓÉÏ.¾Í±ä³É¸¡µãÊýÁË
print 5/2.
# **±íʾÇóÃÝÔËËã
print 7**4
# º¯ÊýÓÃʱҪ¼ÓÉÏmodule.function
import math
print math.floor(19.8)
# º¯ÊýÃûÒ²¿ÉÒÔ³ÉΪ±äÁ¿
func = math.floor
......