Python ÖÐÈçºÎдif
python
content=str.find('ok') && content=str.find('not ok')
ÕâÑù±íʾ ÔÚÄÚÈÝÖÐÕÒµ½ ok »òÕß ÕÒµ½ not ok ¶ÔÂð£¿
²¢ÁÐÌõ¼þÓà and ¶ø²»ÊÇ&&
»òÕßÌõ¼þÓà or ¶ø²»ÊÇ||
ÄãµÄÒâ˼Ӧ¸ÃÊÇor ÄãÊǶ¼´íÁË
ÕÒ±¾½Ì³Ì¿´¿´°É£¬¿ÉÒÔgoogleËÑË÷python
content=str.find('ok' or 'not ok')
¿ÉÒÔÕâÑùдÂð£¿
ÏÂÃæÓÐÒ»¾äÊÇ
if content <> -1:
.............
ÄÇÎÒÉÏÃæµÄ content=str.find('ok' or 'not ok') ¶ÔÂð£¿
Ö»ÄÜÉÏCSDN ²é²»ÁË Ï²»ÁË
http://search.download.csdn.net/search/python
¿ÉÒÔ be more pythonic way
>>> s = 'is it ok for ya?'
>>> if 'ok' in s:
... print 'affirmative'
...
affirmative
>>>
Ïà¹ØÎÊ´ð£º
ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º
1¡¢·áºñµÄ¸å³ê¡£
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......
´ó¼ÒºÃ£¬ÎÒÊÇÒ»¸öÐÂÊÖ£¬¸Õ¿ªÊ¼Ñ§python£¬µ«ÊǸտªÊ¼µÄhelloworld¶¼Ã»·¨´òÓ¡£¬ÈÃÎÒºÜÎÞÄΡ£
ÎÒµÄpython°²×°Â·¾¶Îªf:\python31¡£ÔÚpathÖÐÒ²ÉèÖöÔÁË£¬ÔÚwindowsÏÂÔËÐÐÊÇÕâÑùÏÔʾµÄ£¬Ï£Íû¸÷λǰ±²Ö¸µãһϡ£Ð»Ð»
Pyth ......
ÔÚlistÖÐÌí¼ÓÒ»¸öÀàµÄ¾Ö²¿±äÁ¿ ÕâÑù×öÊÇ·ñºÏ·¨ Çë¿´ÏÂÃæÀý×Ó:
Python code:
class A():
def __init__( self ):
self.__a = 0
self.__b = 'hello'
def get_a( self ):
ret ......
>>> x=-1
>>> if x>0:
print ('11')
>>> else:
SyntaxError: invalid syntax (<pyshell#20>, line 1)
ÍøÉÏËѵÄÒ²ÊÇ£º
>>> x=int(input("Please ent ......
import os,sys,zipfile
teststr = open('1.txt').read()
zipFile = zipfile.ZipFile('test.zip','w')
zipFile.writestr('test.txt',teststr)
zipFile.close()
É ......