python学习------1.0入门
来源:互联网 发布:php项目开发流程 编辑:程序博客网 时间:2024/04/30 13:53
上一段源码,看看python的语法和运行
import sys
import os
class test(): -------------------------类
def __init__(self,name1='test',age1=0):---------------类似与构造方法
self.name=name1
self.age=age1
def setfun(self,new_name,new_age):-----------------成员方法
self.name=new_name
self.age=new_age
def getfun(self):-----------------成员方法
return self.name,self.age
def show(self):-----------------成员方法
print "My name is:%s,and the age is:%d"%(self.name,self.age)
if __name__ == '__main__':-----------------main方法
title=raw_input("please enter of name:")
print "the enter of string is:",title
tt=test()
tt.show()
tt.setfun("tester",22)
tt.show()
print tt.getfun()
再上一段源码,看看python的语法和运行
class adds:
def __init__(self,values=0):
self.values=values
def __add__(self,other):
return self.values + other
class minus:
y='hello'
def __init__(self,v=0):
self.va=v
def __sub__(self,other):
return self.va - other
if __name__ == '__main__':
a=adds(9)
aa=a+3
print aa
m=minus(4)
print m-2
print m.y
#s=a?x:y-----注释
x=4
s='good' if x%2==0 else 'bad'-----------if偶数 s='good' else s= 'bad'
print s
- python学习------1.0入门
- 001--Python入门学习
- python学习入门
- python入门学习之一
- python学习入门
- Python入门学习 :)
- Python 画图学习入门
- python入门学习
- python 学习快速入门
- python入门学习
- 【学习】Python语言入门
- Python入门学习(一)
- python学习入门
- python入门学习
- Python学习01---入门
- Python入门学习
- python入门学习笔记
- python入门学习
- CentOS7 安装JDK1.8
- 大量并发SQL导致数据库性能问题诊断优化
- ubuntu 16gcc g++版本降级
- CSS3 flex弹性布局
- TensorRT 2 初探秘 (一)
- python学习------1.0入门
- 文件对话框(QFileDialog)
- LeetCode (12)Integer to Roman
- 什么是PLC的响应时间
- Dojo与jQuery综合比较分析
- iOS 开发修改 searchbar 的背景颜色
- PLSQL连接Oracle报错ORA-12541:TNS:无监听程序
- 文章标题 CSU 1838: Water Pump (单调栈)
- Image对象