python_day2】的更多相关文章

一.字符串的基本使用 #!/usr/bin/env python #!-*- coding:utf-8 -*- #!/usr/bin/env python  指定解释器为python abc='hello,world' #把'hello,world' 赋给abc对象 print abc.count('l') #统计'l'字符出现的次数 print abc.capitalize()#首字母变成大写 print abc.center(30,'-')#字符长度为30,并居中 左右两边的空白处使用'-'…
基本数据类型 1.数字 int(整型) 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1,即-2147483648-2147483647 在64位系统上,整数的位数为64位,取值范围为-2**63-2**63-1,即-9223372036854775808-9223372036854775807 1 1)int --> string 2 str是保留关键字, 3 >>>a = 10 4 >>>str1 = str(a) 5 6 2)str…
1.bytes数据类型 msg = '我爱北京天安门' print(msg.encode(encoding="utf-8")) print(msg.encode(encoding="utf-8").decode(encoding="utf-8")) >> b'\xe6\x88\x91\xe7\x88\xb1\xe5\x8c\x97\xe4\xba\xac\xe5\xa4\xa9\xe5\xae\x89\xe9\x97\xa8' (b代…