python基础

快速学习链接:

      http://www.cnblogs.com/vamei/archive/2012/09/13/2682778.html

 

number bool str 

	转义:
		/n 换行
		/r 回车
	
        
	字符打印操作:

	>>> print("hello \\n world.")
	hello \n world.
	>>> print(r"hello \n world")
	hello \n world


	字符的组合,切割:(字符串运算):

	>>> "hello "+"world"
	'hello world'
	>>> "hello"*3
	'hellohellohello'
	
	>>> "hello world"[0]
	'h'
	>>> "hello world"[1]
	'e'
	>>> "hello world"[-1]
	'd'

	>>> "hello world"[0:4]
	'hell'
	>>> "hello world"[0:-1]
	'hello worl'
	>>> "hello world"[0:20]
	'hello world'
	>>> "hello world"[6:]
	'world'
	>>> "hello world"[-5:]
	'world'




	系列类型: list
	>>> ["one","two","three","four"][0:]
	['one', 'two', 'three', 'four']
	>>> ["one","two","three","four"][-1:]
	>>> ["one","two","three","four"][0]
	'one'
	>>> ["one","two","three","four"][0:2]
	['one', 'two']
	>>> ["one","two","three","four"]+["five","six"]
	['one', 'two', 'three', 'four', 'five', 'six']
	>>> ["one","two","three","four"]*2
	['one', 'two', 'three', 'four', 'one', 'two', 'three', 'four']
	>>> type([1,2])
	<class 'list'>

	嵌套分组
	>>> [["1","11"],[2,22]]
	[['1', '11'], [2, 22]]

	元组类型:
	>>> (1,True)
	(1, True)
	>>> (1,True,"22")
	(1, True, '22')
	>>> (1,True,"22")*2
	(1, True, '22', 1, True, '22')

	>>> type((1,2))
	<class 'tuple'>


	当为一个元素的时候,元组与系列显示
	<class 'list'>
	>>> type([1])
	<class 'list'>
	>>> type((1))
	<class 'int'>
	>>> type(("srt"))
	<class 'str'>
	>>> (1)
	1
	>>> (1,)
	(1,)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值