python基础02

python基础02

格式化输出

%占位符,s:字符串,d digit 数字

%%只是单纯显示%

# %s d
name=input('请输入姓名:')
age=input('请输入年龄:')
height=input('请输入升高:')
msg=我叫%s,今年%s,身高%s"%(name,age,height)
print(msg)
msg='''----------info of AlexLi---------
Name :  Alex Li
Age    :   22
Job     :   Teacher 
Hobbie:    girl
------------------end-----------------------'''
print(msg)
name=input('请输入姓名:')
age=input('请输入年龄:')
job=input('请输入工作:')
hobbie=input('你的爱好:')
msg='''----------------info of %s-----------
Name  :  %s
Age     :   %d
job      :    %s
Hobbie :    %s
------------------end----------------------'''%(name,name,int(age),job,hobbie)
print(msg)

 

name=input('请输入姓名:')
age=input('请输入年龄:')
height=input('请输入身高:')
msg="我叫%s,今年%s,升高%s,学习进度3%%s"%(name,age,height)
print(msg)

 


  

while else

当while循环被break打断,就不会执行else的结果

count = 0
while count <= 5
        count + = 1
        if count == 3:break
        print('Loop',count)
else:
       print('循环正常执行完啦')
print('-------out of while loop--------')

 

count = 0
while count <=5
         count + = 1
          if count == 3:pass
          print('Loop',count)
else:
      print('循环正常执行完啦')
print('----------out of while loop-------')

 


  

初始编码

电脑的传输,还有储存的实际上都是01010101010

美国:ASCII码 为了解决这个全球化的文字问题,创建了一个万国码,Unicode

最开始

1个字节 表示所有的英文,特殊字符,数字等等

2个字节,16位表示一个中文,不够,Unicode一个中文用四个字节表示

升级版:utf-8

中文 9万多字

8位bit=1字节byte

utf-8一个字符最少用8位去表示,英文用8位  一个字节

欧洲文字用16位去表示   两个字节

中文用24位去表示   3个字节

utf-16 一个字符最少用16位去表示

gbk 中国人自己发明的,一个中文用两个字节16位去表示

1bit  8bit=1byte

1byte 1024byte=1KB

1KB   1024KB=1MB

1MB   1024MB=1GB

1GB    1024GB=1T

#and or not 

#优先级,()>not>and>or

#print(2 > 1 and 1 < 4)

print(2 > 1 and 1 < 4 or 2 < 3 and 9 > 6 or 2 < 4 and 3 < 2)

#T or T or F T

#T or F T

'''x or y x为非零,则返回x'''

print(1 or 2)#1

print(3 or 2)#3

print(0 or 2)#2

#ps  int--------bool  非零转换成bool True  0转换成bool是False

print(bool(2))

#True

#bool---int

print(int(True))#1

print(False)#0

'''x and y x True ,则返回y'''

print(1 and 2)#2

 

posted @ 2019-02-19 22:36  微光半夏  阅读(195)  评论(0编辑  收藏  举报