标签:font 编译 数字 bigger code family led span pycha
接下来学会了变量:用简单的变量来代替复杂的字符串
变量首字母不能是数字或者特殊符号~!@#¥等。
字符集的发展:
ASCII 255个 1个占1bytes------>1980年 GB2312 支持7千多汉子--------->1995年,GBK10,支持2W多汉子------>2000年,GB18030支持27000多汉子,-----Unicode,汉子占2bytes,但是出现英文不好存储------->utf8,1个英文占1个字节,1个汉子占3个字节
例一:(在pycharm中编译运行,之后的代码都是一样)
方法一:
name=input(”name:”)
age=input(“age:”)
job=input(“job:”)
salary=input(“salary:”)
info=’’’
------ info of % ---------
Name:%
Age:%
Job:%
salary:%
‘’’%(name,name,age,job,salary)
print(info)
方法二:
name=input(”name:”)
age=input(“age:”)
job=input(“job:”)
salary=input(“salary:”)
info=’’’
------ info of {_name} --------
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
‘’’.format(_name=name,_name=name,_age=age,_job=job,_salary=salary)
print(info)
接下来是账户密码的校对:
_username=’xiangxiao’ #(默认取值要用单引号)
_password=’abc123’
username=input(“username:”)
password=input(“passwoed:”)
if _username==username and _password==password :
print(“welcome {name} come here..”.format(name=username))
else :
print(“failed password or username”)
注:在pycharm中编译的时候,注意首行缩进,IndentationError表示缩进错误
循环注意事项:
break:结束当前的循环
continue:结束本次循环,直接进行下一次循环
例二:猜年龄,实现给出实际年龄,要求猜三次年龄,超过三次,则退出循环;
oldboy_age_of=56
count=0
while count<3:
guess_age=int (input(“guess_age:”))
if guess_age==oldboy_of_age :
print(“you are right”)
elif guess_age<oldboy_of_age :
print(“please guess bigger”)
else :
print(“please guess smaller”)
if count==3 :
guess_confirm=input(“do you want to guess it?”)
if guess_confirm !=’n’
count=0
else:
print(“you have tried too much.. ”)
标签:font 编译 数字 bigger code family led span pycha
原文地址:http://www.cnblogs.com/pythonbz/p/6283980.html