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

pythonÓï·¨½éÉÜ

1.1. Óï·¨
1.1.1. if
>>> x=int(raw_input("please enter an integer:"))
please enter an integer:-8
>>> if x<0:
...  print 'negative'
... elif x==0:
...  print 'zero'
... else:
...  print 'positive'
...
negative
ÕâÀïÓм¸¸ö֪ʶµãÐèÒªÌáÐÑ£º
1¡£ºÍshellÖÐifÓï¾äµÄÇø±ð
ÎÒÃÇÀ´»Ø¹ËÒ»ÏÂshellÖеÄifÓï¾ä¡£
shellÖÐifÓï¾äµÄ½á¹¹ÊÇ£º
if ±í´ïʽ
then ÃüÁî±í
[else]
fi
¾Ù¸ö¼òµ¥µÄÀý×Ó£ºifsingle
#!/bin/bash
#filename:ifsingle
echo "please enter the first string:"
read word1
echo "please enter the second string:"
read word2
echo "_______________"
if test $word1 = $word2 ÕâÀï×¢Òâ$word1ºÍ$word2Ö®¼äµÄµÈºÅǰºó±ØÐëÓпոñ£¬²»È»¾Í±ä³ÉÁ˸³ÖµÓï¾ä£¬³ÌÐòµÄ¹¦ÄܾÍÌåÏÖ²»³öÀ´ÁË¡£
 then
 echo " the first string is equal to the second string"
fi
echo "the program has finished"
²¢ÇÒifÓï¾ä¿ÉÒÔÎÞÏÞ²ãµÄǶÌ×ÔÚÆäËûifÓï¾äÖС£
pythonÖеÄÊÇÒ»¸öif£¬elif,elseÓï¾äʵÏÖ¶à·ÅжÏ
ÎÒÃÇͬÑù¾ÙÒ»¸öÏàËÆµÄÀý×Ó£º
ʹÓÃvi±à¼­Æ÷½øÐб༭£º
#!/bin/bash
#filename:ifelif
echo "please enter the first argu:"
read str1                            z×¢ÒâÕâÀïÇв»ÒªÊ¹ÓÃ$1£¬ÒòΪ$1ÊÇÖ¸³ýÁ˳ÌÐòÃûµÄµÚÒ»¸ö²ÎÊý
echo "please enter the second argu:"
read str2
echo "please enter the third argu:"
read str3
if test $str1 = $str2 -a $str2 = $str3 test ÓÃ[ ]ÊÇtestµÄÓï·¨£¬ÐèÒªÓÃ-a±íʾÂß¼­Ó룬µ±È»test Ò²¿ÉÒÔ²»ÊµÓÃ[]
 then
 echo "the three argu are same"
 elif test $str1 = $str2
 then
  echo "the first argu is equal to the second argu"
 elif test $str2 = $str3
 then
  echo "the second argu is equal to the third argu"
 elif test $str1 = $str3
 then
  echo "the third argu is equal to the first argu"
else
echo " they are different"
fi
2


Ïà¹ØÎĵµ£º

ÎÒµÄVIMÅäÖÃ(ubuntu+python)

1£¬²»ÓÃÐÞ¸Ä/etc/vimϵÄvimrc¼°gvimrcÎļþ ¡£¡£¡£
      2£¬ÔÚ~Ŀ¼Ï£¬Ð½¨Ò»¸ö.vimrcµÄÅäÖÃÎļþ¡£ÄÚÈÝÈçÏ£º£¨¸ßÁÁ£¬×Ô¶¯¶ÔÆë£¬×Ô¶¯Ëõ½ø£¬ÏÔʾÐкţ©
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2006 Nov ......

¡¾Python¡¿ÓÃPythonʵÏÖÒ»¸ö¶íÂÞ˹·½¿éÓÎÏ·

¶íÂÞ˹·½¿éÓÎÏ·£¬Ê¹ÓÃPythonʵÏÖ£¬×ܹ²ÓÐ350+ÐдúÂ룬ʵÏÖÁ˶íÂÞ˹·½¿éÓÎÏ·µÄ»ù±¾¹¦ÄÜ£¬Í¬Ê±»á¼Ç¼Ëù»¨·Ñʱ¼ä£¬ÏûÈ¥µÄ×ÜÐÐÊý£¬ËùµÃµÄ×Ü·Ö£¬»¹°üÀ¨Ò»¸öÅÅÐаñ£¬¿ÉÒԲ鿴×î¸ß¼Ç¼¡£
ÅÅÐаñÖаüº¬Ò»ÏµÁеÄͳ¼Æ¹¦ÄÜ£¬È絥λʱ¼äÏûÈ¥µÄÐÐÊý£¬µ¥Î»Ê±¼äµÃ·ÖµÈ¡£
¸½Ô´Â룺
from Tkinter import *
from tkMessageBox import *
i ......

Python³õѧ±Ê¼Ç£¨×ªÔØ£©


while µÄÓ÷¨£º
while ºóÃæ¸úÌõ¼þ±í´ïʽ£¬(:)ºóÃæ¸úÓï¾ä¿é£¬Äã¿ÉÒÔÔÚÕâ¶ÎÓï¾ä¿éÀïÐÞ¸ÄÌõ¼þ±í´ïʽµÄijЩ±äÁ¿£¬µ±Ìõ¼þ±í´ïʽ Ϊ¼ÙµÄʱºòÍ˳öÑ­»·¡£ÀýÈ磺
flag = 5
while flag > 0:
#ÕâÀïÊÇÄãµÄ´úÂë
flag -= 1
#if flag == 3: break
#if flag == 3: continue
print flag
µ±È»ÄãÒ²¿ÉÒÔÔÚÊʵ ......

¡¾Python¡¿ÓÃPythonÀ´ÊµÏÖ´Õ24µÄ³ÌÐò

´Õ24ÊǾ­µäµÄÒæÖÇÓÎÏ·£¬¶àÍæ¿ÉÒÔʹÄÔ½îÁé»îÒ»µã£¬µ«Êǵ±Óöµ½ÎÞ½âµÄʱºò£¬¾Í»áºÜÉËÄԽΪ´Ë£¬Ð´¸ö³ÌÐòÀ´´úΪ¼ÆËã¡£
ÔËÐнá¹û£¬È¥³ýÁËÖØ¸´µÄһЩ±í´ïʽ£º
entry: 1
entry: 4
entry: 5
entry: 6
(4/(1-(5/6))) = 24
(6/((5/4)-1)) = 24
Press any key to exit...
entry: 3
entry: 3
entry: 8
entry: 8
(8/(3-(8 ......

python »ù´¡

   Python¿ìËÙÈëÃÅ
                        Ŀ¼
1. µÚÒ»Õ Python¿ìËÙÈëÃÅ
                &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ