零基础python教程:字符串
1、a = "This is a string";
b = 'This is a string';
着两种声明没有任何区别,着和c的语法不同。c中的单引号代表一个字符;

1、a = "This is a string";
b = 'This is a string';
c = a[5:];
d = b[1:2];
print c;
print d;
print c + d;

1、# -*- coding: utf-8 -*-
a = "This is a string";
if "is" in a:
print "[1] is in String"
else:
print "is not in String"
print a.find("iss"),a.find("is")

1、a = "This is a string";
b = 1
c = 1.2312
d = "%s,%d,%.2f" % (a, b, c)
print d;

1、Python 中定义一个 Unicode 字符串和定义一个普通字符串一样简单:
a = u'this is unicode string !'
print a;
引号前小写的"u"表示这里创建的是一个 Unicode 字符串。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:125
阅读量:162
阅读量:155
阅读量:96
阅读量:155