day02-2018-10-18-python基础

占位符

#%表示占了一个位置,等着后面来填,
# info='''
# =============%s
的名片==========
#     -----
姓名:%s-----
#     -----
电话:%s-----
#     -----
公司:%s-----
#     -----
职位:%s-----
# ===============================
# '''
# print(info%('VastTry','VastTry','1388309xxxx','Google','CEO'))

 


#%s
是万能的,:
# print('
我叫VastTry,今年%s'%12)#接受一个整型的12
# print('
我叫VastTry,今年%s'%'12')#接受一个str类型的12
#
结果是一样的
#我叫VastTry,今年12
#我叫VastTry,今年12


#%d能接受整型的数字,和浮点型数字
#print('我叫VastTry,今年%d'%'12')#%d format: a number is required, not str
# print('
我叫VastTry,今年%d'%12.0)#我叫VastTry,今年12
# print('我叫VastTry,今年%d'%12)#我叫VastTry,今年12

 


#注意事项,代码如下
#print('他叫%s,拥有全国0.01%的财产'%'马云')#TypeError: not enough arguments for format string
#print('
他叫马云,拥有全国0.01%的财产')#他叫马云,拥有全国0.01%的财产

 

运算符

#首先要知道
#x or y ,if x==false then y else x
#x and y ,和
x or y 相反
#()>not>and>or
#试题如下
:
print(11 or 12)
#11
print(0 or 12)
#12
print(1 and 2)
#2
print(0 and 1)
#0
#接下来 来点别的有意思的
,True 相当于1 False 相当于0,但是不等于
print(2>1 or 2 )
#True
#True or 2<==> 1 or 2 -->True
print(1>2 or 2)
#2
#False or 2 <==> 0 or 2-->2
print(2>1 and 2)
# True and 2 <==> 1 and 2 -->2
print(1>2 and 2)
#False and 2 <==> 0 and 2 -->0-->False

编码

#1.ASCII 码有 128 个
#本来用7位二进制就刚好能装完
#方便以后扩展 增加到256个 即8位

# 2.GBK, 中文现在大概有90000多个汉字,
# 一开始设计的
GBK位16位
# 2**16=65536基本满足日常使用

#3.Unicode 32bit 4byte ,占用空间大

#4,utf-8可変长的unicode
# 英文
:8bit 1byte 
# 欧洲文字
: 16bit 2byte
# 中文
:24bit 3Byte
原文地址:https://www.cnblogs.com/VastTry/p/9812023.html