1、注释:#hello world ;
2、字符串
a.单引号 和 双引号 没有区别,>>>'let's go' 等同 >>>‘let\'s go’ 此处用\‘转义
b.拼接字符串:
>>>x='hello'
>>>y='world!'
>>>x + y 输出 'hello world!' (字符串和数据不能相加)
c.str函数 和 repr函数
>>> print str('hello world') 结果为 hello world (给用户看到的结果)
>>>print repr('hello world') 结果为 'hello world' (以python表达式的形式来表示)
d.原始字符串print r ('hello \n:world') 结果为 : hello \n:world 和输入一模一样; python3 中没有原始字符串 r 这样的用法;
二、列表 和 元组
1、列表和元组,列表可以修改,元组不能.
2、通用序列操作:
a.索引:序列中所有元素都有一个编号,从0开始递增;>>>a='hello' >>>a[0] 结果为 h,如果索引是-1,则从序列最后一个元素开始,最后一个元素的位置就是 -1. >>>a[-1] 结果为 o;
3、分片:>>>a[3,2] 包含前者不包含后者
4、分片可以使用更大的步长:>>>a[0:10:a] 此处步长为 a,步长如果为负数,则第一个位置必须在第二个位置的右侧,否则为空;
5、序列相加;>>>[1,2,3]+[4,5] 结果为[1,2,3,4,5] ;字符串和序列不能拼接;
6、None 是代表空值,此处N必须大写;
----------------------------------------快乐的分割线-----------------------------------------------------------------------------
明天继续坚持!good bye