创建一个 Pure Python 3.5,2
New directory 目录
创建一个程序 声明一个解释器
Vietw File and Code Templates
写程序
运行print("hello world ")右击
变量
什么是变量?变量是用来干嘛的?
变量是用来存东西的,存东西是为了以后来调用的。
不存就被内存释放了。存在内存里。
怎么定义一个变量name ="Alex Li"
c++string name ="Alex Li"
#调用
print(“My name is”,name)??My name is Alex Li
New directory 目录
创建一个程序 声明一个解释器
Vietw File and Code Templates
写程序
运行print("hello world ")右击
变量
什么是变量?变量是用来干嘛的?
变量是用来存东西的,存东西是为了以后来调用的。
不存就被内存释放了。存在内存里。
怎么定义一个变量name ="Alex Li"
c++string name ="Alex Li"
#调用
print(“My name is”,name)??My name is Alex Li
name = "Alex Li"
name2 = name
print("My name is ",name ,name2)
name="PaoChe Ge"
print(name,name2) ?? Alex Li PaoChe Ge
name2 = name
print("My name is ",name ,name2)
name="PaoChe Ge"
print(name,name2) ?? Alex Li PaoChe Ge
name 本来指向的是“Alex Li”
name2指向的是name指向的(name只是向name2指一条路,name2并不会随着name的改变而改变。)
name2指向的是name指向的(name只是向name2指一条路,name2并不会随着name的改变而改变。)
标识符
数字、字母、下划线
首字符不能是数字
约定俗成 变量名一定要能看懂(虽然Python能是中文执行但是千万不要去用)
gf_of_oldboy="chen rong hua"
数字、字母、下划线
首字符不能是数字
约定俗成 变量名一定要能看懂(虽然Python能是中文执行但是千万不要去用)
gf_of_oldboy="chen rong hua"
变量
常量 在Python里是没有这个概念的
若想要定义一个常量 变量名要大写
常量 在Python里是没有这个概念的
若想要定义一个常量 变量名要大写
字符编码
计算机
底层储存
两种状态 通电和不通电
计算机只能表示01要想表示2怎么办?
古代烽火
弊端:传递的信息量很少
1-100
101-1000
1001-5000
古时候的人们就这样想的
23004
准确的怎么办?
0 0 0 1 1 1 2 1
0 0 0 1 1 0 1 1
64 32 16 5 4 2 1
1 0 0 1 0 0 1
153
弊端:传递的信息量很少
1-100
101-1000
1001-5000
古时候的人们就这样想的
23004
准确的怎么办?
0 0 0 1 1 1 2 1
0 0 0 1 1 0 1 1
64 32 16 5 4 2 1
1 0 0 1 0 0 1
153
ASCII 255 1bytes
1980 GB2312 7xxx
1995 GBK1.0 2W+
2000 GB18030 27XXX
unicode 2bytes
utf-8 en:1 zh:3
密文的设置
passwd
import getpass
username =input("usename")
password=getpass.getpass("password")
print(username,password)
1980 GB2312 7xxx
1995 GBK1.0 2W+
2000 GB18030 27XXX
unicode 2bytes
utf-8 en:1 zh:3
密文的设置
passwd
import getpass
username =input("usename")
password=getpass.getpass("password")
print(username,password)
import getpass
_username = 'alex'
_password = 'abc123'
username =input("usename:")
password=getpass.getpass("password:")
if _username == username and _password=password:
print("Welcome user {name} login...".format(name=username))
else:
print("Invalid username or password!")
#input默认读的结果是字符串
age_of_oldboy=56
guess_age = input("guess age:")
if guess_age == age_of_oldboy:
print("yes, you got it. ")
elif guess_age > age_of_oldboy:
print("think smaller...")
else :
print("think bigger!")
age_of_oldboy=56
guess_age = input("guess age:")
if guess_age == age_of_oldboy:
print("yes, you got it. ")
elif guess_age > age_of_oldboy:
print("think smaller...")
else :
print("think bigger!")
循环
count = 0
while True:
print("count:",count)
count = count + 1
count = 0
while True:
print("count:",count)
count = count + 1
guess
age_of_oldboy =56
count=0
while True:
if count == 3
break
guess_age = int(input("guess age:"))
if guess_age == age_of_oldboy:
print("yes,you got it.")
break
break
elif guess_age > age_of_oldoy:
print("think smaller...")
else:
print("think bigger!")
count+=1
else:
print("think bigger!")
count+=1
count = 0
while True:
print("count:",count)
count+=1
if count == 1000:
break
while True:
print("count:",count)
count+=1
if count == 1000:
break
age-of-oldboy =56
count=0
while count<3:
guess-age =int(input("guess age:"))
count=0
while count<3:
guess-age =int(input("guess age:"))
if guess-age=age-of-oldboy:
print("yes,you got it.")
break
break
elif guess-age == age-of-oldoy:
print("think smaller...")
else:
print("think bigger!")
count+=1
else:
print("you have tried too many times..fuck off")
else:
print("think bigger!")
count+=1
else:
print("you have tried too many times..fuck off")
for i in range(10):
print("loop",i)
0123456789
age-of-oldboy =56
for i in range(3):
guess-age =int(input("guess age:"))
for i in range(3):
guess-age =int(input("guess age:"))
if guess-age=age-of-oldboy:
print("yes,you got it.")
break
break
elif guess-age == age-of-oldoy:
print("think smaller...")
else:
print("think bigger!")
else:
print("you have tried too many times..fuck off")
else:
print("think bigger!")
else:
print("you have tried too many times..fuck off")
for i in range(0,10,2):
print("loop",i)
02468
print("loop",i)
02468
for i in range(0,10,3):
print("loop",i)
0319
print("loop",i)
0319
age-of-oldboy =56
while count< 3:
guess-age =int(input("guess age:"))
if guess-age=age-of-oldboy:
print("yes,you got it.")
break
print("yes,you got it.")
break
elif guess-age > age-of-oldoy:
print("think smaller...")
else:
print("think bigger!")
count+=1
if count == 3:
countine_confirm = input("do you to keep guessing..?L")
if countine_confirm !='n':
count = 0
else:
print("think bigger!")
count+=1
if count == 3:
countine_confirm = input("do you to keep guessing..?L")
if countine_confirm !='n':
count = 0
for i in range(0,10):
if i<3:
print("loop",i)
else:
continue
print(hehe...)
if i<3:
print("loop",i)
else:
continue
print(hehe...)
break
for i in range(10):
print('-------',i)
for j in range(10):
print(j)
if j<5:
break
print('-------',i)
for j in range(10):
print(j)
if j<5:
break
博客员
编写登录接口
—输入用户用户密码
—认证成功显示欢迎信息
—输入三次后锁定
—输入用户用户密码
—认证成功显示欢迎信息
—输入三次后锁定
import getpass
username
password
getpass.getpass
username
password
getpass.getpass
判断
存用户密码
_username='alex'
_password='abc123'
if_username ==username and _password ==password:
print( )
存用户密码
_username='alex'
_password='abc123'
if_username ==username and _password ==password:
print( )
小的一个登陆程序
超过三次还是这个登陆名去锁定
Python自带的文件处理
用户名对应的密码
来源:https://www.cnblogs.com/qxiaohong/p/12219412.html