f是format函数的缩写

python中的f是format函数的缩写,用于格式化输出。
python有两种除法,普通除法 a/b ,不论a,b精度 得到的都是浮点数;a//b , 得到一个舍弃小数位的整数结果,所以结果永远是小于等于普通除法的解
大小写敏感
交互模式下,上次输出的表达式会赋给变量 _

round函数 round(price, 2)
支持 复数:3+5j

π是使用math.pi变量来表示的
import math
math.pi
pai = _
print(pai)
round(pai,3)


'doesn\'t' # use \' to escape the single quote...      转义字符
'"Yes," they said.'
"\"Yes,\" they said."
'"Isn\'t," they said.'

print('First line.\nSecond line.') # here \n means newline!


>>> mystr1='Hello Kity'
>>> mystr2='PPP'
>>> print(mystr1,mystr2)  # 用,分开多个对象
Hello Kity PPP      (有空格)
>>> print(mystr1+mystr2)   # 用 + 合并字符串
Hello KityPPP     (无空格)

用+连接的需要同类型

print('gh'+6)  # 报错

posted @ 2023-04-22 23:02  sangern  阅读(414)  评论(0)    收藏  举报