Python打卡
https://www.cnblogs.com/yuxuefeng/articles/9235431.html
跟着安装最新的Anaconda3和Pychram
我安装对应的是python3.7.6版本的
Pychram因为2020年查得比较严,新版的好像也无法**了。只能先试用30天。先打卡30天再说
编码方法
ord()这个函数将字符转换成对应编码,整数
chr()这个函数将编码转换成对应字符
字符串拼接(与java的字符拼接不太一样)
sth='新世纪%d'%(ord('A'))+'字符拼接'
print(('ABC'.encode('ascii'))) #encode()是字符转编码
print(('汉语'.encode('utf-8')))
print((b'ABC'.decode('ascii'))) #decode()是编码转字符串
print((b'\xe6\xb1\x89\xe8\xaf\xad'.decode('utf-8',errors='ignore'))) #编码转换成字符的时候忽略错误
print('\u4e2d\u6587')
另外一种写法
sll='my name is {0},the banana is {1:0.1f} yuan'.format('wolf',10.23)
print(sll)
使用format()的方法也可以占位
使用f'string'也可以替换里面相对应的字符串