1、// 整除运算(向下取整)
%取余运算
** 乘方运算 (2**3=8)
2、OxAF=176 (十六进制)
Oo10=8(八进制)
Ob1011010010=722(二进制)
3、避免输入结果后立即关闭打印窗口
input("press ")
4、字符串拼接
“hello”+name (字符串加字符串变量混合拼接)
name1+name2(字符串变量+字符串变量拼接)
“hello1”+“hello2”(字符串+字符串拼接)
5、避免与字符串原有的单/双引号重复,程序报错
“Let’s go!” 双引号字符
’ “hello,world!” '单引号字符
" “hello,world!” " → ’ “hello,world” '( \转义字符)
6、\n换行
7、str(类),repr(函数)
print(repr("hello,\nworld!"))
>>>'hello,\nworld!'
print(str("hello,\nworld!"))
>>>hello,
>>>world!
8、长字符串,跨越多行的字符串
print('''This is a very long string.11111111111111111111111111111111111111111''')
print("""This is a very long string.11111111111111111111111111111111111111111""")
*常规字符串也可以跨越多行,在行尾加上转义字符\
print("hello,\
world!")
>>>hello,world!
适用于表达式
1+2+\
4+5
>>>12
print\
("hello,world!")
>>>hello,world!
9、原始字符串r,用于绝对路径中包含大量的反斜杠/,不对反斜杠做特殊处理
(原始字符串不能以单个转义字符结尾)
path = 'c:\noway'
print(path)
>>>c:
path = r'c:\noway'
print(path)
>>>c:\noway
path = 'c:\\noway'
print(path)
>>>c:\noway
10、约定使用大写字母组合的变量名表示常量,有不要对其进行赋值的提醒作用
PI=3.141592653