简明Python学习笔记1.基础

0、python注释:

      单行:#

      多行:'''      '''

1、字面常量:字面上的意义

2、数字:int  和 floats 

3、字符串:''  or " " (the same) 

     多行字符串:"""  or  '''

     字符串不可变

4、格式化方法 format(name,age )

format 方法所做的事情便是将每个参数值替换至格式所在的位置

    name {0}  or { }

    age {1} or { }

5、print自动换行,若不需要

print('a', end='')  a后输出空格  print('a',end=' ')

6、转义字符

     \  \n :换行    \t:制表符   于行末:该行继续

'What\'s your name?'      如果:输出  What's your name?  

7、原始字符串

    让字符按其表面意思来使用

for  example:

 print(r'Newlines are indicated by \n')
输出:Newlines are indicated by \n        
 print('Newlines are indicated by \n')    \n换行
输出:Newlines are indicated by 

>>> 

8、变量

     标识符:字符、下划线、数字

9、数据类型

     数字(整数、浮点数)and 字符串

10、物理行:我看到的

       逻辑行:Python看到的

       一行执行一个语句

       若一行执行多个,用  隔开

       for example:

i= 5
print(i)
#the same as
i = 5;print(i);

11、显示行连接

i = 5

#the same as

i = \
5

猜你喜欢

转载自blog.csdn.net/m7kise/article/details/80272485