python入门基础
来源:互联网 发布:怎么做淘客软件 编辑:程序博客网 时间:2024/06/05 20:58
len()
type(a)
print ('hello' * 4)
输入input
a = int(input('Enter an integer: '))
元组tuple_小括号(不能重新赋值、删除)
tuple_a = (2,)
number = (1,2,3)
number[1]
temp = ('tom', 18, True)
列表list_中括号:
函数:len(list)、max(list)……
方法:list.reverse()、list.sort([func])……
nubmer = [1,2,3]
del number[1]
print ("number: " + str(number))
cities = ['Nanjing', 'Jian', 'Shenyang']
len(cities)得3
print cities[1]
字典dictionary_大括号(键值对,key和value)
tom = {'name': 'tom', 'age': 18}
print tom['name']
grade = {'tom':99, 'nancy':86, 'landy':90}
print ("nancy: " + str(grade['nancy']))
条件语句
a = 12
if a > 10:
print True
else:
print False
循环语句
str = 'hello'
for i in str:
print i
for i in range(1,10):
print(i)
else:
print('the for loop is over')
list_a = [1,3,5]
for i in list_a:
print(i)
函数
def getName():
return 'tom'
def getName(name):
return 'hello ' + name
def multiParas(a, *b, **c):
print(str(a) + srt(b) + str(c))
调用函数
print getName()
print getName('nancy')
multiParas("hello",1,3,5,word="python",another="c++")
模块
法一:
import math
math.sin(30)
math.cos(30)
法二:
from math import *
sin(30)
cos(30)
range(5)得[0,1,2,3,4]
自定义模块
文件名:test.py
def getName(name):
return 'hello ' + name
调用自定义模块
from test import *
getName('tom')得hello tom
类
文件名: test.py
class People(object):
def getName(self, name)
return 'hi ' + name
使用类
from test import *
student_01 = People() #实例化一个类
student_01.getName('tom')
- Python基础:Python入门
- python 基础入门
- python基础入门
- python基础入门
- Python基础 - 快速入门
- Python基础入门(2)
- Python入门基础
- Python爬虫入门基础
- python基础入门一
- Python入门基础
- Python基础入门
- Python基础入门
- Python 基础入门
- python dataframe基础入门
- python-入门基础语法
- python入门基础
- python入门基础0
- Python 入门基础
- 求m和n的算法题
- 洛谷P1848 [USACO12OPEN]书架Bookshelf
- Spring Bean的生命周期
- Java编程思想之I/O系统
- Html5实现自己的分页加载
- python入门基础
- Spark系列1 Spark 安装
- Java并发编程艺术 5 Java中的锁
- springboot入門(一) helloworld
- session与cookie的区别与联系
- [Tensorflow]基于slim框架下inception模型的植物识别
- c++中非静态函数不能用类名调用,为什么CWnd的成员函数GetDC()可以直接调用啊?
- 反射获取属性值
- 版权声明:本文为博主原创文章,未经博主允许不得转载。 今天重写一个delphi7的CS架构的软件,原本自带的控件是Indy9。现在升级到Indy10,用delphi XE5开发。发现idTcpSer