1.位运算

&(与)

| (或)

~ (非)

^(异或)

2.三元运算

c = a+b if a>b else a-b

if (a>b):

a+b

else:

a-b

3.小知识(通过键盘输入密码,密码在输入时不显示)

import getpass

password = getpass.getpass("password:")

4.格式输出

mes = “my name is {0}, my age is {1} years old”

print ("mes.format("kate",12)")

使用变量:&{0},&{1}

5.字典

names = {stu1:"kata",
               stu2:{name:"rose",age:22}
               sut3:"mike"
             }
print(names[stu1])
print(names[stu2][name])
 
del names[stu1]
 
04-23 15:46