![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
ShanRui_
https://github.com/mengxiangrui007
展开
-
Python函数
函数参数def say_hello(): print('hello word')say_hello()say_hello()函数变量def print_max(a,b): if a > b: print(a,'is max') elif a == b: print(b,'is equal to',a) else: print(b,'is max')print_原创 2017-06-02 16:51:06 · 318 阅读 · 0 评论 -
Python模块
import sysprint('The command line arguments are:')for i in sys.argv: print(i)print('\n\nThe PYTHONPATH is',sys.path,'\n')创建模块eg:def say_hi(): print('Hi, this is mymodule speaking.')__vers原创 2017-06-02 16:56:26 · 428 阅读 · 0 评论 -
Python数据结构
列表shoplist =['apple','mango','carrpt','banana']print('I have',len(shoplist),'items to purchase.')print('This items are:',end=' ')for item in shoplist: print(item,end=' ')print('\n I alse have原创 2017-06-02 17:01:56 · 390 阅读 · 0 评论 -
Python面向对象编程
实现文件备份类class Person: passp = Person()print(p)方法class Person: def say_hi(self): print('Hello Person class')p = Person()p.say_hi()__init__ 方法class Person: def __init__(self,name): s原创 2017-06-02 17:06:59 · 383 阅读 · 0 评论 -
Python输入输出
输入内容def reverse(text): return text[::-1]def is_palindrome(text): return text == reverse(text)something = input('Enter text: ')if is_palindrome(something): print('Yes ,it is a palindr原创 2017-06-02 17:10:38 · 338 阅读 · 0 评论 -
Python异常
处理异常try: text = input('Enter somint -->')except EOFError: print('Why did you do an EOF on me?')except KeyboardInterrupt: print('You Cancelled the operation,')else: print('You ente原创 2017-06-02 17:13:26 · 517 阅读 · 0 评论 -
Python控制流
python学习代码都来之于 《简明Python教程》最新版本if:number = 23guess = int(input('Enter an integer:'))if guess == number: #新的代码块从里开始 print('Cougratulations,youguess it.') print('(but you do not win any prizes!原创 2017-06-02 16:43:05 · 397 阅读 · 0 评论