OSX从Pthon 2.7升级到3.8 1,官网下载最新安装包安装 2,执行认证文件command 3,执行设置path command 4,设置默认python 在terminal里运行open ~/.bash_profile,打开~/.bash_profile,直接修改文件保存,重启Terminal. source ~/.bash_profile # Setting PATH for Python 3.8 # The original version is saved in .bash_p
python出输出字符串方式: >>> who='knights' >>> what='NI' >>> print ('we are the',who,'wha say',what,what,what,what) we are the knights wha say NI NI NI NI >>> print ('we are the %s who say %s'% (who,(what+' ')*4)) we are the kni
Python中Unicode字符串 字符串还有一个编码问题. 因为计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字节(byte),所以,一个字节能表示的最大的整数就是255(二进制11111111=十进制255),0 - 255被用来表示大小写英文字母.数字和一些符号,这个编码表被称为ASCII编码,比如大写字母 A 的编码是65,小写字母 z 的编码是122. 如果要表示中文,显然一个字节是不够的,至少需要两个字节,而且
python列表和字符串的三种逆序遍历方式 列表的逆序遍历 a = [1,3,6,8,9] print("通过下标逆序遍历1:") for i in a[::-1]: print(i, end=" ") print("\n通过下标逆序遍历2:") for i in range(len(a)-1,-1,-1): print(a[i], end=" ") print("\n通过reversed逆序遍历:") f