PythonÈëÃŵÄ36¸öÀý×Ó——17 Return
# 017
def lifeIsAMirror():
string = raw_input()
if string == 'I love you!':
return 'I love you, too!'
elif string == 'Fuck you!':
return ''
else:
return
# end of def
string = lifeIsAMirror()
if len(string) == 0:
print 'You have nothing.'
else:
print string
# end of if
output:
1
2
3
4
5
6
>>>
Fuck you!
You have nothing.
>>>
I love you!
I love you, too!
Ïà¹ØÎĵµ£º
·¢
Ïֺܶ๫˾ҪÇóÕÆÎÕһÎű¾ÓïÑÔ£¬Ò»Ö±Ò²Ïë¸ã¸ãÕâ¸ö£¬¿´C++£¬Linux
C±à³ÌÒ²Ö»ÊÇΪÁ˶Ôϵͳ¸ü¼ÓµÄÁ˽⣬°¦£¬ÎҵŤ×÷¶¨Î»ºÃÏñÒ»Ö±¶¼²»ÔõôÃ÷È·£¬ÊÇÒª¸ã¸ö×Ô¼º×îÉó¤µÄÁË£¬ÒÔºóÓÐʱ¼äÔÙ¸ãlinuxC£¬ÕÒ¹¤×÷µÚһλ¡£¡£¡£¹¤
×÷»ù±¾¶¨Î»ÔÚ Java+python£¬´ó²¿·Ö¹«Ë¾Ò²²»»áÒªÇóÒ»¸öÈ˼È×öJavaÒ²×öC++¡£ÔÙ˵ÕâÓïÑÔÒ²ÊÇ´ ......
ÓÃpythonдÁ˸ö×î¼òµ¥µÄ¶Á´®¿ÚµÄ³ÌÐò£¬ÒòΪ¹¤×÷Öо³£ÐèÒª¶Á´®¿Ú
·ÅÔʼ´úÂë
import serial
ser = serial.Serial('com3',baudrate=115200, bytesize=8,parity='N', stopbits=1,xonxoff=0, timeout=1)
while( True ):
a = ser.read(100)
print a
ÓÃÍêÐèÒªser.close()£¬·ñÔòÆäË ......
ÔÚÍøÉÏËѲ»µ½¹ØÓÚ Ascii ºÍ bcd»¥Ïàת»¯µÄÎÄÕ£¬ÓÚÊÇ×Ô¼ºÐ´ÁËÒ»¸ö£¬ºÍ´ó¼Ò·ÖÏíÏ¡£
ûÓп¼Âǵ½Ð§ÂÊ£¬Äܹ»ÓÅ»¯µÄµØ·½Íû´ó¼ÒÌá³ö
"""
AscII×Ö·ûת»»ÎªBCD×Ö·û
"""
def asc2bcd(inAsc, pad_L0_R1 = 0):
#È«²¿×ª»»Îª´óд£¬ÎªºóÃæµÄת»»Ìṩ·½±ã
inAsc = inAsc.upper()
&nb ......
1. Basic
²Î¿¼¡¶PythonÕýÔò±í´ïʽ²Ù×÷Ö¸ÄÏ¡·
Ä£¿ére£¬perl·ç¸ñµÄÕýÔò±í´ïʽ
regex²¢²»Äܽâ¾öËùÓеÄÎÊÌ⣬ÓÐʱºò»¹ÊÇÐèÒª´úÂë
regex»ùÓÚÈ·¶¨ÐԺͷÇÈ·¶¨ÐÔÓÐÏÞ×Ô¶¯»ú
2. ×Ö·ûÆ¥Åä(ÑÐò½¥½ø)
Ôª×Ö·û
. ^ $ * + ? { [ ] \ | ( )
1) "[" ºÍ "]"³£ÓÃÀ´Ö¸¶¨Ò»¸ö×Ö·ûÀà±ð£¬Ëùν×Ö·ûÀà±ð¾ÍÊÇÄãÏëÆ¥ÅäµÄÒ»¸ö×Ö·û¼¯¡£Èç[ ......
Python´úÂëÓÅ»¯--ÉÙ´ò×ÖС¼¼ÇÉ
˵Ã÷£ºÔö¼Ó´úÂëµÄÃèÊöÁ¦£¬¿ÉÒԳɱ¶¼õÉÙÄãµÄLOC£¬×öµ½¼òµ¥£¬²¢ÇÒÕæÇÐÓÐÁ¦
¹Ûµã£ºÉÙ´ò×Ö£½¶à˼¿¼£«ÉÙ³ö´í£¬10´úÂëÐбÈ50ÐиüÄÜÈÃÈËÃ÷°×£¬ÒÔϼ¼ÇÉÓÐÖúÓÚÌá¸ß5±¶¹¤×÷ЧÂÊ
1. ½»»»±äÁ¿ÖµÊ±±ÜÃâʹÓÃÁÙʱ±äÁ¿£º(cookbook1.1)
ÀÏ´úÂ룺ÎÒÃǾ³£ºÜÊìÁ·ÓÚÏÂÃæµÄ´úÂë
temp = x
x = y
y = ......