pythonµÄһЩ²Ù×÷
# 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
print func(1.9)
# ¿ÉÒÔÓà + À´Á¬½ÓÁ½¸ö×Ö·û´®
print "abc" + "def"
# Èç¹û¾ä×ÓÖÐÓÐ ’£¬¿ÉÒÔÓÃ\'´úÌæ
print 'He\'s a student'
# »òÕßÓÃË«ÒýºÅ
print "He's a teacher"
# ×Ö·û´®¿ÉÒÔË÷Òý
print "abcdefgf"[3]
# ½«Êý×Ö±ä³É×Ö·û´®µÄÈýÖÖ·½·¨
x = 12345
print 'number:' + str(x)
print 'number:' + repr(x)
print 'number:' + `x`
# ÊäÈëÊý×ֵķ½·¨
x = input('Please Enter a number:')
print x
# ÊäÈë×Ö·û´®µÄ·½·¨
xx = raw_input();
#print xx
# ³ÌÐò½áβ¿ÉÒÔ¼ÓÉÏÕâÒ»ÐУ¬³ÌÐò¾Í²»»áÒ»ÉÁ¶ø¹ýÁË
raw_input('Press Enter to Continue...')
Ïà¹ØÎĵµ£º
À´Ô´:
×÷Õß:
Áé½£
1.python ×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨...£©¡¢ÈýÒýºÅ£¨...£©»ò£¨'''...'''£©°üΧ£¬ÈýÒýºÅ°üº¬µÄ×Ö·û´®¿ÉÓɶàÐÐ×é³É£¬Ò»°ã¿É±íʾ´ó¶ÎµÄÐðÊöÐÔ×Ö·û´®¡£ÔÚʹÓÃʱ»ù±¾Ã»Óвî±ð£¬
1.python
×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨"..."£©¡¢ÈýÒýºÅ£¨"""... ......
Ê×ÏÈתÔØÒ»¶Î¹ØÓÚÍƼöµÄѧϰpythonµÄÊé¼®£¨ÔÎÄÁ´½Ó£©£º
1.ѧϰ¡¶A Byte of Python¡·£¬ÖÐÎÄÒëÃûΪ¡¶Python¼òÃ÷½Ì³Ì£¨pdfÏÂÔصØÖ·£©¡·£¬È«ÊéÏÂÀ´Ö»ÓÐ100¶àÒ³£¬¼òµ¥¸ÉÁ·£¬Í¨Ë×Ò׶®£¬Êǹ«ÈϵÄPythonÈëÃŽ̡̳£ÎÒËäȻϵ½ÁË¡¶Python¼òÃ÷½Ì³Ì¡·pdf°æ£¬µ«ÊǾõµÃÆäÖеĴúÂë¿ÉÄÜÊÇÒòΪÒëÕßת»»ÎĵµÀàÐ͵ÄÔÒò£¬¸ñʽ±äµÃºÜÂÒ£¬ËùÒÔ× ......
ÏÈ˵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 ......
def MergeSort(mylist, low, mid, high):
i = low
j = mid + 1
tmp = []
while i <= mid and j <= high:
if mylist[i] <= mylist[j]:
tmp.append(mylist[i])
i = i + 1
else:
tmp.append(mylist[j])
j = j + 1
......
ÎҵĻ·¾³ÊÇ£º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 ......