代码搜索结果

找到约 11,834 项符合 Python 的代码

continue.py

#!/usr/bin/env python # Filename: continue.py while True: s=raw_input('Enter something : ') if s=='quit': break if len(s)

simplestclass.py

#!/usr/bin/env python # Filename: simplestclass.py class Person: pass # An empty block p=Person() print p

method.py

#!/usr/bin/env python # Filename: method.py class Person: def sayHi(self): print 'Hello, how are you?' p=Person() p.sayHi() # This short example can also be written as Person().sayHi()

mymodule_demo2.py

#!/usr/bin/env python # Filename: mymodule_demo2.py from mymodule import sayhi,version # Alternative: # from mymodule import * sayhi() print 'Version',version

list_comprehension.py

#!/usr/bin/env python # Filename: list_comprehension.py listone=[2,3,4] listtwo=[2*i for i in listone if i>2] print listtwo

func_local.py

#!/usr/bin/env python # Filename: func_local.py def func(x): print 'x is',x x=2 print 'Changed local x to',x x=50 func(x) print 'x is still',x

expression.py

#!/usr/bin/env python # Filename: expression.py length=5 breadth=2 area=length*breadth print 'Area is',area print 'Perimeter is',2*(length+breadth)

helloworld.py

#!/usr/bin/env python # Filename : helloworld.py print 'Hello World'

using_file.py

#!/usr/bin/env python # Filename: using_file.py poem='''\ Programming is fun When the work is done if you wanna make your work also fun: use Python! ''' f=file('poem.txt','w') # open for

mymodule.py

#!/usr/bin/env python # Filename: mymodule.py def sayhi(): print 'Hi, this is mymodule speaking.' version='0.1' # End of mymodule.py