标签:log nbsp 模板 ascii 需要 int end form family
在pycharm中设置程序模板:
#!usr/bin/env python #声明环境变量 ,Windows不需要 #-*- coding:utf-8-*- # Author burnywen
变量:
name = "burnywen" print("burnywen")
name = "burnywen" name2 = name print(name,name2) name = "banana" #name2直接指向burnywen,不随name改变而改变 print(name,name2) 输出: burnywen burnywen banana burnywen
二进制:
十进制:130 128 64 32 16 8 4 2 1 二进制 1 0 0 0 0 0 1 0
ASCII:
十进制 | 对应字符 |
48—57 | 0—9 |
65—90 | A—Z |
97—122 | a—z |
格式化:
name = input("name:") age =int(input("age:")) #转换为integer job = input("job:") salary = int(input("salary:")) info = """ ----------info of %s------------ name:%s age:%d job:%s salary:%d """%s(name,name,age,job,salary ) print(info) info2 = """ #特定场景下只能用这种 ----------info of {_name}------------ name:{_name} age:{_age} job:{_job} salary:{_salary} """.format(_name = name, _age = age, _job = job, _salary = salary) print(info2) info3 = """ ----------info of {0}------------ name:{0} age:{1} job:{2} salary:{3} """.format(name,age,job,salary) print(info3)
guess_age小游戏:
#!usr/bin/env python #-*- coding:utf-8-*- # Author burnywen age_of_burnywen = 23 count = 0 while count <3: age = int(input("guess age:")) if age == age_of_burnywen: print("you are right") break elif age > age_of_burnywen: print("think smaller...") else: print("think bigger...") count += 1 if count ==3: retry = input("do you want to try? y/n") if retry != "n": count=0 continue else: print("end...")
标签:log nbsp 模板 ascii 需要 int end form family
原文地址:http://www.cnblogs.com/beyount/p/7198563.html