>>> a= 'py' >>> b= 'thon' >>> a+b 'python'
>>> a=1 >>> type(a) <type 'int'> #a是整数 >>> b="1" >>> type(b) <type 'str'> #b是字符串 >>> print "one is %d"%a one is 1 >>> print "one is %d"%b #报错了,这个占位符的位置应该放整数,不应该放字符串。 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: %d format: a number is required, not str
>>> print "one is %s"%b one is 1 >>> print "one is %s"%a #字符串是包容的 one is 1
>>> a = "py" >>> b = "thon" >>> print "%s%s"%(a,b) #注
>>> a = "My name is LaoQi. I like python and can teach you to learn it." >>> print a My name is LaoQi. I like python and can teach you to learn it. >>> b = a >>> print b My name is LaoQi. I like python and can teach you to learn it. >>> print a My name is LaoQi. I like python and can teach you to learn it.
>>> a="hello" >>> len(a) 5
>>> m = len(a) #把结果返回后赋值给一个变量 >>> m 5 >>> type(m) #这个返回值(变量)是一个整数型 <type 'int'>
S.upper() #S中的字母大写 S.lower() #S中的字母小写 S.capitalize() #首字母大写 S.istitle() #S是否是首字母大写的 S.isupper() #S中的字母是否便是大写 S.islower() #S中的字母是否全是小写
>>> a = "Hello,World" >>> a.upper() #都是大写 'HELLO,WORLD' >>> a.lower() #都是小写 'hello,world' >>> a.capitalize() #首字母大写,其余小写 'Hello,wold' >>> a.istitle() #首字母是否是大写,如果是返回True,不是返回False True >>> a 'Hello,Wold' >>> b="hellow,world" >>> b.istitle() #首字母不是大写,返回false False >>> a.islower() #是否字符串中都是小写,如果是返回true,不是返回false False >>> b.islower() True
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有