在前面提起过字符串这个词,现在就来学习什么是字符串。

  首先,字符串是python内置的数据类型,其特点是用引号引起来,并且可以是使用单引号('字符串'),双引号("字符串"),三个引号('''字符串''' 和"""字符串""")。注意,这些符号都是半角符号,且是英文的引号,也就是不能用中文输入法中的引号。

  这些字符串在单独使用,且都是一行的时候,并没有任何差别,例如:

a = ''
b = ""
c = ''''''
d = """"""

  还能够使用类的方式创建 str() :

a = str('')
print a

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbUAAAAzCAIAAACfVgH7AAAGJ0lEQVR4nO2cy5XrNgxAWRZLSCPDMuQKwp03STrQdrh3FdropAE3wSz04weUaFvSOJ57zztzxnoUCQIgCELyqH8BAEBC/bQAAABvCvERAECG+AgAIKP+AgAACeUBAECC+AgAIEN8BACQqY6P/U3rW//qcJ1RjVKte7UfifeX8Bxcq3bQwy5j3a1eV2ZntlVd0+YnqNXz7h61q0KO85Yz/fAwhvg4+PFFqYsyXaHl3eqrDabrzHSLupgHzPWUdfubVk08ViDzaIZUwmd5twVZY52osXGjdYzzvb3W3fikYJM5SkpbV+bdfm0uoZo25xPOfZN9Pepu9V69PTSLN+n5VJT3vrdXbe/ee+87Uw75QTM/Nh6s3t/0qvl7ewv+9wlfCVaIa6etuLOTzG7qLpOwlpclPJBK64wsm/Y8i8OmEyYI/U0rcT2cpMzYgsfe5f2jydHPe5Q803gWe+rwuJ7PRXnvw7QrkCkzanqArYyPST9P+Ep4S3p7pMQnj9ivS3gc91rrjI3zhO6g6cQJgmuVaY2QpZ6jzOdGeVq2R5OjH/eoTW8ptXm3ns9Gee/r5XAmmXZ45h0/GjdkeRel2u/xl+HfslytvSp1WXK98fg8BIKxXpO2GRpmOayNG4QSOtMo1RrTTP2cIWGEcNfV9nFBKmqT84iXRJu2EB+Xkkic942jTzpx48XyXelYg9rjc9/Qm75q1f5tr0pdtW6Ubr90M2psHm4RONNq2kaSJ7bgd2EWY51hrs8Idq/SRjz3zqjGmFapizFt2aadifww88zSWLlv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OnK73VREgA+AXM+aMzS9Qr/S5fAAD4SMT4uNBbrYM/i2o4XQPAr2EtPsbBcaUhAMAHUoyPzighOEotAQA+Ejk+9lYHD2ts9HymHDgBAD6J8Pn1/Aw7+KzUGA2XaySPAPAr4P1wAAAZ4iMAgAzxEQBAhvgIACBDfAQAkCE+AgDIEB8BAGSIjwAAMsRHAAAZ4iMAgAzxEQBAhvgIACBDfAQAkCE+AgDIEB8BAGT+A/hHDym4N7uqAAAAAElFTkSuQmCC" alt="" />

  不过传参的时候还是要加引号,所以一般不这样创建。

  上面几种写法是一种意思,另外,要注意引号引起来的都属于字符串类型,就算里面是数字或其他数据类型也一样。所以,当对字符串使用加法的时候,得到的不是数学上的相加,而是字符串的拼接

  如上所示,但一般我们不这样进行字符串的拼接,因为这里的拼接方法非常低效,浪费内存空间。例如:

a = '' + ''

  此时,会在内存中创建 '' ,再创建 '' ,然后将其拼接成 '' 后又放到内存中,最后再用变量指向内存中的值。这个过程中我们额外创建了两个值,而这额外的值是我们所不需要的。如果大量拼接的话,肯定会产生大量的无用数据,不仅浪费内存,还会触发python的垃圾回收机制,而python在垃圾回收的时候,是不做其他事情的,这样我们的代码效率就会非常低。


1.字符串的拼接

  除了使用+号进行拼接之外,还要2种方法可以实现拼接(其实还有一个使用+=符号的拼接方法,而且貌似效率不错,但我也是看别人的文章看到的,个人不是太清楚原理,所以就不说了)。

  1.'io.StringIO',内存字符串IO拼接(从内存层面操作,用的很少,也没怎么了解过,这里不多说明)

   2.str.join(),使用字符串的join()方法(str是创建字符串对象的类,到面向对象的时候会详细解释,这里看代码演示先)

a = ''      #先创建一个空的字符串,按面向对象的说法叫创建对象
a.join(('abc','def')) #使用join()方法拼接字符串,而join()方法继承于父类

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAA6CAIAAABZO9AOAAACk0lEQVR4nO2bW5KsIBAF3fXd02yS+bgxNkIBBUp70MwvpyzAkAweLbMFABm2ux8A4AM6ghDr6bj9bNtP+thmEJbj04X/NqM7/cFvYpqHjg/g0IVLGImLDybtxSWMhKdySj6PkdsfnhxPMjwYu+OvMjIWC8mgyfTRMTgGSEZH+M/0tePuFpJBk7k7ayZr6GL6747MwuAHP0AIdAQh0BGEeIuO5rL1s+ufcALDX+fXWq+/BAXkjlA4307XS/R0g0eIXm/8yZVMZ6N5mv1xX9vI9Y5QDNDsg0u8mZfpT8gv0syFdAxPNPLaDrjl6NB5Xw/JwkZKHKGoZObBUiS+SGow22o+T/ibAePO3iP5zGjGz2DWmUTiHO9SdS0dw61HKEpFck2TP0tfI4fffiJBb/AkXQ0xOhaDRhs9n2SGdXRmVoL282SjUXwrD15FqaHSkNlR80I63n6EQkrH+hbhFh2bye2aV9HxO0co6iPl5TqakVLwkDBhsu6YJeZM1souhnDHEQq/jnHxZoX5danOSjDNySbH5lamXWf/OsHcu5hpY60r6ijCpFcj0g33drzIS6ig8ihd2x14KnQ/CBGvyYLa2CT4SDCVZMnvKDCkiLNUnoaOr+IwOnrLDCnSLLUn5BfwEkY6fLaO8Fo8v1Slc+geySdWZ3ISiXOQ8s20vkxsxvWMYGB0BOdknQ9m8a08mN9NMktDJrwc12RduigF87vNzEoc3gOTNQjRsZXZ59bmVqZe3MxkKwOBj4QgBTqCELN05HgODICOIMSs0+DoCAMcjLnQSHSEAVJjLvwPa3SEXk7JVzESHWEA25jzRqIjDMDoCEKwdgQh2FmDEPzuCELwVQaEQEcQAmNACHQEIdARhEBHEOIXrhmj9WR1/A4AAAAASUVORK5CYII=" alt="" />

  这里加入了从面向对象的解释,如果看不懂,可以在学完面向对象后回来,我当时学的时候也是一脸懵逼,但学完面向对象之后,我才有一种顿悟的感觉,以后我会分享我对面向对象的一些理解。

  总结一下其的用法:

  1.先要有一个字符串的对象,该对象由str这个python的内置类创建,否则没有 join() 存在。

   2.语法格式是 str.join(sequence) ,其中sequence代表一个序列,在Python中有六种内建的序列:列表、元组、字符串、Unicode字符串、buffer对象和xrange对象(后面会有总结)。

  也就是说除了像示例那样传一个元祖之外,还能传字符串,那么是否可以这样写呢:

b = ''
b.join('','')

  答案是不可以,会出现报错,报错信息如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdQAAABbCAIAAABF1OOCAAAOC0lEQVR4nO2dS5KruBKGtZu+S9CGrF20vYKrmUe9BMYadEQPPOsVHMeNZgXtTegOQM/UCwwIu/4vKirqcEBKJeh3khgl01/F+LjIV28jfjY4BQA0wY7qSA2MXZl4LjzsKRYc9RT8MS627Mt4SX4LXU23tBy1nlHehXq/GQC+m1h8n4Ld2Pxz3XgKqWHN3G4+CnPeQZ3W4sZ1JygBPgUBqBKL70MqOwmfctv7x33F9ynYsIX2vqTcRIC69n6o+CZsVmLrT24Avg0S+SrtJqFSm8rQruK7VdS2WfTXtfcjxTd5VLSxr1cBOCPJnK83VZSYU4GjvHs5wSlFeGNesDnKe5SsmA+xd6BqYGIQ7MbYXc6bGtoxYXgl+etsfkl+ZfzO2ZVfBu76Iva4HMuVy5cZ7Lwl2VfGG7TlmjfmDPhDcueNau+ZlhM+3Eh8acvNHoPaAlChJr7zP81ki3ewf4wPPk1Rf4sRmvlYNUzTeJR3t6XajhXf8mT2bVYD44/R/g7tSfReGHuyo8gbdKSt3rjLkVhe7j3rn1o7K8S33EW5ZYgvABUaxZdMJBPyXLPTUg1xTJSaw83tuAA2g/eQZ2rE/53pfY5A/adDLeLbPtKF3ljTO/VhzoDlaYd0yw0ew8NPAGqsE1+zZZT3OGK1j19srKf1OJpYLxN7ltqZ93nJS+UBuhJGoJPim4h8H8H+4dCy+W7qDTrSRm/kxTfbe9Y/ng+TRr4R+bqWWz32knyTh58AfDFUfMcHTyf1gthzyn7yy8DjPaMcq5+9fUg1Ne5mZq2dKck4qCmTW5GPKfidMpWDEPb3bFKcmZ1HGn6pzgw/GbjlvEEzvBVvzIHwVSiXR672nms59OH/TKLW7vMiWyjpfcKW/230WCLsRRYCgJjDXrI4Brxe1R2cAgCa+DLxBQCAzwDiCwAAHYD4AgBAByC+A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UNZT2MS1EHzxu5fh5y0teSHTjfPiINYVCjzKRLy0T53q3ka//WCmyOdlvdCXk7UmcQRp7WpvzDiQeS+xDtyhxzYpv4VpNiW/5yYd3bUSFqTJHtX3sKRF+ZaLRZhSd+iSo+JryNtH9YCBAamD8zks5xPirZl6ei6bVAmkjOd/EPq2KTIKCTQoUNQUXxo12z6lNfhk4u3L5t5j7fUke5fW8o+ZGKl/XC46y9+bKz/lGvfs1kzzHBjbbAC12frVWHslOJrwajzSFZ/Pvv2WNCU+i+XqyEANjv/P/3BgbhLC/Xd280GOp807OYAZzbbjgtJKjj2wmQ5icGH/5rMVmhL0fRetLFl5qUn9MXmmXAkU//T2i8Eroy+IswT4suiT2s/mnX5kfR1V81RB/Js9R7dqHYAdg4gIUKNqSxJXQnWx4fmI+0WawB9/9ejEAAJwUiC8AAHQA4gsAAB2A+AIAQAcgvgAA0AGILwAAdADiCwAAHYD4AgBAByC+AADQAYgvAAB0AOILAAAdgPgCAEAHIL4AANABiC8AAHQA4gsAAB2A+AIAQAcgvgAA0AGILwAAdADiCwAAHYD4AgBAByC+AADQAYgvAAB04P9IOm6dp6bJPgAAAABJRU5ErkJggg==" alt="" />

  具体意思是,函数只要一个数据,我们却给了两个,所以报错了。

  也就是说当我们这样写的时候,其实是传了两个序列进去,一个字符串就是一个序列。

  那么,如果我们只传一个字符串呢?

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMwAAAA2CAIAAAAESeHaAAACDklEQVR4nO2dUZKDIAxAufXeqZd0P7pDFRKIYKhr3pt+2GwEV9/QyEibNgMpHV5FRMx03b0bFPeFb8G5B3eQDNxBMnAHycCdg2Q/UnlsDwqtp5QoucNTGuDh2cBhwZOYUsriGZKBbMCFnqUdA8cHD0C98Fd5tncLz2KyYiQTtyEOS2syJIvJ0rtLJIuJ7zzZRuEPzPjDApAM3EEycOcgmfhwH0/8wSSlPqJPSAYzlCOZkIFhMAcGgTtIBu4gGbiDZOAOkoE7SAbuIBm4g2TgDpKBO0gG7gSSLD81mV4pvS7+x8U2eU7zzR1XkBt3OdVykaxJJojySrVAWnDyIJ9KlBXkh6UGumENb/J2N6j1G5YQK8jtx2CRrJE/2ftTudcKcjGzDmqR/UbRQrfrv0xdGiQb5o4ryLVdavmKt5/SvpnZ6vpkrWZqE8nE6HdXkA9LZsxsdX1yuGIks7C0JvuPkrU1QjILS+8u9x9njVN/uWRiRO569O5SbTC8YZv3PNmmFP52yfYtiG3u6/16W2tT7rea/coRLd5vE8nuOePvdGHWX28Me3OjsyCOQPAAuKLgTlG4XL/KkgXoUN+FKXlVPJ35cSSITDmSyUlNb/J2Nwgxsc9EqG/5cgNoMyhZ909IBplZybRaDSAzJdnZ4Q1iMi5ZWyMkg8yVhX/3bgBiYnySoqy0kvQT4GImADqAO78/yFW7yofYsAAAAABJRU5ErkJggg==" alt="" />

  好像没有问题,那当b不是空的时候呢?

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAI0AAABSCAIAAADmVMAIAAAC/0lEQVR4nO2cUXbEIAhF3XX31E3aj+nJOAYRFYww735ZSojhVSXG05SBB9LTHRgm/ab0q9xti5i6vDv3k4iOyo1E6JSSzHMUSU5HU+9Gp2wj1Vy3uJjihFp4PkXdP12pjMaTkPOzL2dJla5UqUDoNj1bvia6UpvLUgnWsp8M3VEtqcqMm46tSp5R4/mYjyeyfXdbH0/5NqS6Ojli3/pkvVbdlQirk2m9h3lvBcP3pyyuI1Qoq4OXAN06wrpLinjq6zcDnXwAnXzwLTpdC+S2bVzdJfm4fVjhJUORK+eWTkSuxWUIGVNRKn/7sBN8vB60RWJSP/dOZqVTjrUPO9oHiU6M/+LdO3Hupv37sJUzb2xZykYVoXvrf8923k/UKT+6D9u65K5f9eO7UmA9uVsPrluimF7GE9meuKSrk9CTu/XgoHlyPD2+D3uUTrwSj+m0Zx+WX67UdSIt9K1n671mQIt6b9s+rFynMgIZsywf7u1WTPq+7Odg0t6PaVeXP47is20Iu+2Op+hEjgNwgbz4oJz3c7C/5khPVK23Dafe045m5OXPX6ISM6BOjEiSp5VnpPTsSrUSM4xIWbg+na/T+lWHM6nTfZK5LPeZh5nlyAiKMcMwo1N3kuGNfJyVmJEKh4r5ea/6ix5dISxiCh08Mj/vtRotIx9wPSYf3DsPzHvbjJGQbCZ2VvLXr7prPnPtesyWMQxBHysc0MkH0MkH0MkHb50OOQ8LSD7yGPU8bADqPMY7DxuDJVV0z8MCBjp97v4vQXjMxxPZBqPsW5+g0wr76j3otILh+1NGHaEH0ucD6OQD6OSDcp3X/8gW+MPdZj6yKMnpaOqhkwof40l6jYEn4JlJJLK/n5lzLN3jJRBSne4GHdH+zpNZzyI9v1eOkrnjj2AF0bzXarSMQB3Mez4YqCPmjqkCFZBUH0AnH0AnH0AnH9h+zwVa2J6PAFrYnjcCWtie3wNa2J6HBVpgPPkA65MPUO/5AO9PPkDGfQCdfACdfACdfACdfACdfPAHYQltuebhWRMAAAAASUVORK5CYII=" alt="" />

  这和我们想象的不一样,并不是直接拼接在最后面。很明显这不是我们想要的(坑爹啊这是),如果传的是元祖呢?

  (注意,join()并没有改变b的值,只是返回了一个新对象,关于返回值会在函数中讲)

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPMAAABBCAIAAACLlgUWAAADBElEQVR4nO2cUXKEIBAFvXXulEuaj60YI8wwIIo+ur/MLIK7dM0OLJVlBVBkGf0AjSzfy/Ld+eGv6BNGcZzIryUztfHgnVgWpvGPsoe4Fez7kDCKUx4PlNvR2pF1uy4G4e3k5/IVcltEzHbagwbmpPaVe/kl0ibS2OvHNhWz58Gb1F5y7x1t9jVObf199fPAEG7K2WsgbV+as2sTObydm+rsTdMhOdt3F7MluWNvZGw1Et8bASVu2s/uUmaEBkp2qbeIFb/uYWAgzCtogtmgCWaDJnOZnS3x//Zthp6yum10/0OQ4aEnooIfdNV8RGY04latgvHG/qZ727Pld/cnkPutJ6IaKE5nFwWvaxlvUDzjNanZq6LcfedyyF7hefX/NVaX+0EnopyWadCK7C8OPWTHKj7PWtojz7bsqH5kM97as/e6ndbsdeiJKOuW1PjDn9bP+M0T2Xa8u5fZVQORs/fclLPXmrS9njA72NIJ5p8nyZH7l9JgL6yBrERe0fOcZg8/EfUos/2V2RCzi43LPU9o9j0novz83d3sbMQK/mtwQTVS8d11TTUir/Wamn3biai42fvbix2m11afTvDYJvn2L64gy33WF0LZJWO2Wdvo4mY/hIs+5YfM6FiHHvIhXM2z3k/VKhPAAYdAk3SZtYplTL13BBGyJVfgtnpd0vafTg7xbLBq0GyfMBuZnB29s0YX37btOhusGjTtCq3npH3aT+bsNonjZsPkxPf2j3l3i1jlRLwkKEqc7fMQ2bfBbwj+iJi5ri0nLNus+rthdGcUmI2q3xGPOXL/UhpMbw8GnT6LGRqz4UNFNWJdWEGrByfijxgZCLPhw7Bq5GSfVCPgU72C3L79iytIP+iUE/6qNC1Iss1gclAANMFs0ASzQRPMBk2OZuv9pxGYk1MeIzc8lryayA1vx/QSueHVeFIiN7wXcjZoQp0NmrA3Apqwnw2aYCdogtmgCWaDJpgNmmA2aILZoAlmgyaYDZpgNmiC2aAJZoMmmA2aYDZogtmgCWaDJj8Yi/VI5VwJJwAAAABJRU5ErkJggg==" alt="" />

   嗯,也是个大坑。

  看来是在传入的序列后,按照索引逐一取出的值,在这些值之间插入原来的字符串。

  教练,这个和说好的不一样啊!

  其实我们有更好的方法,那就是字符串的格式化。


2.字符串的格式化

  字符串格式化的原理是,我先在里面占着一个坑,但我暂时不填这个坑,等到要用的时候,在把要填的东西扔进去。

  先看代码示例:

name = 'scolia'
a = '%s是一个帅哥' %name
print a

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAe4AAABVCAIAAAAAD5ADAAAKBUlEQVR4nO2cy5mjuhZGFZZCOImUwsARHM08uicDpq25o2BCBk6CO+ClNzIGbFWv9dVXbcvS1tbrZ7NNtRgAAKByxJ5G/UPKR/9u150SjRCteddOjO/38BpMKw6Yh0P6emqZn8xObU91SZ1PUDrPh++oQyfkvN1y5T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VA9SDgBQPUg5AED1IOUAANXzf0SpTc9iv2PrAAAAAElFTkSuQmCC" alt="" />

    scolia使用了字符串格式化,效果拔群,scolia得到了‘帅哥’称号。

    里面的 %s 就是所说的坑,而外面的 %name 就是我们要想要填入的东西,当然一般我们用变量来储存这个值,如果配合用户交互来动态改变name的值的话,那么人人都能是‘帅哥’了。

  但这样我们还不满足,如果用户是女的呢?还用帅哥就不合适了吧。这个时候,我们可以多占几个坑。

name = 'scolia'
how = '帅哥'
a = '%s是一个%s' %(name,how)
print a

  结果:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAe0AAAA1CAIAAADjzCRaAAAHBElEQVR4nO2cy5mruhJGFRYhnESsMHAEh5lH92TAtDV3FEzIwElwB7z0KAkZY2x1r/Xtz9vGolSSip+iwK0GAAAoGfVpBwAA4CXQcQCAsnlBx/t7Vd37Vx3otKqVas2rdiS+38NzMK06YB4O6evRVOnJ7PT2VOe0+QS583x4RB06Ie+LljPj8I8R0/HxeLsqdVW6i7e5NdayGD3voq76ibDaFYX9vVK125fl8xQuvod7+TbhyFkdp7E20+poM/TNLW/HnY7NyxGbtPRkPprL5qGe0+Z87LFvcmxEPZrqKGtPjeJLLENEx/vmVjWPYRiGodPxU6jVbJgaj9HZ36tkmPbN3fp2R0xbR7Jp59Sma2afzWwu8DCXlz18I5mrM7EmQcso3jYcO+Hq75USj9uTJtNdwffuNQzPJpufjyh5pO4ojpzD91mGmI7baaw1d0Hw+YWLTB337OyIaXsXf3dnsXeWVl738H08cldnahwmyG8ajptwmVbpVgtZ/zmTua+X3b49m2x+PKI2oyXW5tsswzDEdDx/voz2lseudUwftRmz5qtS7c/0Zvy3ykrT3JS6rrnzVDYZBWuqJ/ptxobBNUHjNrA9NLpWqtW6nu2c4aGDsNet6d2CqdMm5JlodpIgQcfXUpibR0+9z3Nipo3xvfy+xml3r/dHa9WtUu3/mptSt6qqVdVeqnqasaW71eFgVv02kj/uCv5ERjHVl5a6nLDuWbPhjr3Tqta6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vuXuj/S2SH4E+fkrH99kEAPgUhwtTqNp9c9n+udmxme+4b+zcsLzGekxs3+0SAMCbOEHH8/w4Lh+3dxRTb0/lE2/S2wEAvoEv0vFD8vG0KOfrOPk4AJRCVJiMnjWsmqsic/1bWX/5u3JaDL6OT1bcv00dmDlmJK70e+9DBd9MwwEAiiCmXFKZuxo3LV/1TVU1/fp/ZEdvy/JxeiNm4l4unNPGH1h8Y1rHd/QFAPBBEqo05tKLQicE2v5qU8ftVF/IyI8Syt06/qxNAIDPEs3Hm0m/7ex7edcckI+v9oYhXpveP7AXdDyWg6PjAPCFxIRpKWIrJ9VWToru1cetfeZNa+ptafaU6F8u1WrrcK1M2BF1PKHX6DgAfDNfIUximnyIzZzt4hbycQAohc8Lky2OoYDuls5EXSVno9gMHQeALwRhAgAoG3QcAKBs0HEAgLJBxwEAygYdBwAoG3QcAKBs0HEAgLJBxwEAygYdBwAoG3QcAKBs0HEAgLJBxwEAygYdBwAoG3QcAKBs0HEAgLJBxwEAygYdBwAoG3QcAKBs0HEAgLJBxwEAyub/e/8JDRG/8OwAAAAASUVORK5CYII=" alt="" />

  没问题,多占几个坑也可以,不过写法上有点变化(改成了元祖的形式,元祖的详细以后会讲),这个时候就可以想怎么改就怎么改了(要美女自己写)。

  理论上用几个占位符都可以,只要有对应的变量就可以(变量和占位符数量不对应是会报错的),而且是按顺序来取代里面的占位符的。

   但如果我们不想按顺序来传呢?可以这样写:

a = '%(name)s是一个%(how)s' %{'how':'帅哥','name':'scolia'}

  结果和上面的一样,用字典的方式传值,然后里面用字典的key去获取,关于字典的详细以后会讲。

  此时,有些人就会问了 %s 中的s是什么意思(你就当有人这样问,别吐槽),这里的s代表我将要用字符串来填这个坑,类似的,我们还可以有以下的写法:

格式 说明
%s 字符串(str()形成的)
%r 字符串(repr()形式的)
%d/%i 有符号整数(十进制)
%u 无符号整数(十进制)
%o 无符号整数(八进制)
%x 无符号整数(十六进制)
%X 无符号整数(十六进制大写字符)
%e 浮点数字(科学计数法)
%E 浮点数字(科学计数法,用E代替e)
%f/%F 浮点数字(用小数点符号)
%g 浮点数字(根据值的大小采用%e或%f)
%G 浮点数字(类似于%g)
%p 指针(用十六进制打印值的内存地址)
%n 存储输出字符的数量放进参数列表的下一个变量中
%c 转换成字符(ASCII 码值,或者长度为一的字符串)
%% 字符‘%’

  这个表是我从网上找的,里面有那……么多类型,是不是我用什么去替换,就要用什么占位符呀,这么多这么记得住?

  很多情况下一个 %s 就已经足够了,因为使用这个标记时,会将传入的数据先用 str() 方法转换为字符串,而python的所有数据类型都能转换成字符串(别人是这样写的),而最终要输出的结果又是字符串(不然怎么叫字符串的格式化)。

  所以,占位符的格式可以总结为:

%[(name)][flags][width].[precision]typecode

  []代表可选,以后都是这样表示。

  (name):用字典的key传值,上面有提到

  typecode:数据类型,也就上面表的那些,一般%s就足够了,当然有需要可以用其他的。

  flags:可以有+,-,' '或0。+表示右对齐。-表示左对齐。' '为一个空格,0表示使用0填充。

  width:表示显示宽度,在设置了宽度后,上面的各种对齐,填充才有效果。

      这些对齐,填充,宽度是什么意思?首先,我有一个字符串'scolia',长度为6,可我硬要用10个字符的长度去显示怎么办,那是不是会多出4个位置,这4个位置怎      么办,是不是可以用空格或者0去填充。但这4个多出来的长度的位置是不是不确定的,那我可以先让原来的字符去占住位置,就是所谓的对齐,对齐后剩下的位置才是      填充的位置。

  precision:表示小数点后精度,配合浮点数使用。

  当然,字符串的格式化还有其他方法,这里这就不继续深入了。


 3.引号的嵌套

  在开始的时候说过,当几种引号单独使用,且只有一行的时候,效果都一样。但是当其嵌套使用的时候,就要注意一些问题,看下面的示例:

a = 'scolia说:'我要说一句话''  #错误写法

  这个时候,就会造成混乱了,就像这里的颜色标识一样,把前面的一段的当成是字符串了,而后面那段又不符合语法,肯定是会报错的。

  所以,这个时候就要这么写了

a = 'scolia说:\'我要说一句话\''
print a

  其中,\ 是转义符号,这里将有意义的引号(')转换成普通的符号,被转义后就失去了引起字符串的含义了。

aaarticlea/png;base64,iVBORw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HeW24La+h+tirKfhDOinNOyT5hN+a+5HlkHdvSwXpTL4g4A+A5qM2VlxdjPi+ff1A6Z8mIv0MpywvieCBYS1dxx9u2qh/X+lHU/dfuTHgEALVO5q+fCLwVJMBH5JeSwpuyd4w4tSbEnzDYFv92EbVfQpsD1jaI8t49yz9T+qnBXeljpVfl46vbquQCA69Lirs4JpdlJhtgMN6e8bI9He8h2kebUEGUAvo92d/XnqXHObMEyq3c5BTzCw5orQeEIAODqYFcDAEBDQJQBAKAhIMoAANAQEGUAAGgIiDIAADQERBkAABoCogwAAA0BUQYAgIaAKAMAQENAlAEAoCEgygAA0BAQZQAAaAiIMgAANAREGQAAGgKiDAAADQFRBgCAhoAoAwBAQ/wPUG9zgwEdjM8AAAAASUVORK5CYII=" alt="" />

  结果也是我们想要的,但是每次都有进行转义实在太麻烦了,此时,我们可以这么做

a = "scolia说:'我要说一句话'"
print a

  在外围使用双引号,在里使用单引号,这样里面的单引号就不会被解释成要创建字符串了。

  当然倒过来也是可以的:

a = 'scolia说:"我要说一句话"'
print a

  结果也是一样。

  但是,有时候我们有这样的需求:

a = 'scolia说:"我要说一句话,这句话很长长长长长长长长长长长长长长长长长长长长长长长长长长长"'
print a

  其结果是这样的:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlYAAAAwCAIAAABc9aMmAAAIdUlEQVR4nO2dzdWzOA+GXRYlTCNxGaSC8S6rbzpg+3ifKtjQQZrgWwDGlmTjEEN+fF9nznMSIiRZ/hGyk3nVuIPh3jT3Yc+dPr1WrVKdfVWPxOd7eA62UwXiUMTWwzTpYPZ6O9Q5Mu8gN87FR1TRgBw3Ws4chwA8g2JXpqXqqtRV6T5y18M0N+ONaKuXW9RVPzEjd03g4d6oNrTl+TzPNOrhXj5tzc3pnUBY27l3tB0Hc8u7cadjS3fEgpYO5sNcNlfJHJnz8du+SdkR9TBNKW1PteJDNAPwKjQFDubWmMc4juPY6/iDmyc2zsLTxB7uTXKGD+bufbpjOfAWQdstD9S9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lrweWv2XF5eLs0sl1iLAy+ldTnVqkXe1ynqJ5rTphMeZnqVvs7dZjJWSz9RLZKHMqxT+YRmHn/IQAYy3yjz27y5wbG0NBbqDLGDY3kuMUSO81A0oSRI0V3KmWzrgnxi5vB44gqu4Mo3XvltPqKpPOJFukFU4i4qD/KpeFdxD2O2YuZiSrhCsWmlrLvXfObkOAwZyEDmu2R+m9rbDwAAoFqQAgEAAFQKUiAAAIBKQQoEAABQKUiBAAAAKgUpEAAAQKUgBQIAAKgUpEAAAACVghQIAACgUpACAQAAVApSIAAAgEpBCgQAAFApSIEAAAAqBSkQAABApSAFAgAAqBSkQAAAAJWCFAgAAKBSkAIBAABUyv8BDBIe0c6y0IUAAAAASUVORK5CYII=" alt="" />

  但这句话太长了,我要进行换行这么办?

  那就要这么写:

a = 'scolia说:"我要说一句话,这句话很长长长长长长长长长长\n长长长长长长长长长长长长长长长长长"'
print a

  其结果是这样的:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAasAAABNCAIAAACXGdwRAAAJAElEQVR4nO2dPZbrKBCFWZaWMBtplqEOXjxkjmZ2oLTJfSadXIl24E1oAv0BVYUwQpLncb+j49NWX1UVBZQQdr+n/vl3wIEDB446D3V7BDhw4MBx16HaXwYHDhw46jzUCAAAtYIKCACoF1RAAEC9HKiAw7NpnsPRAHqtWqU6e9QOx+dHeA22UwXyUMTXyzTxZPZ6P9UpmjtIzXPxEVU0IeeNlivHYTJSBZxG6rdS30r3suZhnAZZvVyivvUbHZLVf8OzUa3vy4l5TnQYYS6fNuVSescTazv3jrbjYB5pF2YGtnSHlLR4Ml/ma3eSpGiux237LmVH1Ms0pay91YoPsXwIvgIO5tGY1ziO49hruWw7snEWT/06PJtoBw/m6fw2YzQ4c8B2y+20N0vMdjFHIkzlcIQnktg7M9uNd23Fac1xb/LDs1HsiL8omX4PnnvVOL67wLl/RPEt9VtRMofnWT4GXwHdpZPjlXRb+JiZWAEDOxmjwb0kvNxLU+aD8PEIz+OV2juzm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CAekEFBADUCyogAKBeUAEBAPWCCggAqBdUQABAvaACAgDqZacCftr3nqD5vTT8/2oAwGW8VwFTvicMDTSpGvK/GgBwMakVUPrLAWigydZI/6sBAJexXwEj4xsaaI5rALgR7ANCc7MGgBsRH17iQAPNQQ0An8Ab+4DQQHOGBoAbQQWE5mYNADfyxj6gNIihgeaIBoAbSaqA8Ts5NNAc0QBwI/sVMBi1OIMzZc8AcCNvPAVDA80ZGgBuBAMUAFAvqIAAgHpBBQQA1AsqIACgXlABAQD1ggoIAKgXVEAAQL2gAgIA6gUVEABQL6iAAIB6QQUEANQLKiAAoF5QAQEA9YIKCACoF1RAAEC9oAICAOoFFRAAUC+ogACAekEFBADUCyogAKBeUAEBAPWCCggAqJf/ALfzifCEoX8UAAAAAElFTkSuQmCC" alt="" />

  其中,\n 的意思就是换行符(当然这里的 \ 也转义符,只不过是将原来没意义的字符变成有意义),到了这里就会换行,另外还要很多特殊字符,这里不逐一列举了。

  但是每次换行的时候都要用 \n 实在太麻烦了,我写的时候自己换行不行吗?

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZ8AAABQCAIAAABJSe8WAAAGRElEQVR4nO2dPW7bShhFZynZg4qwTJktJHXMbVB9ACKVFqDalQDWgZ93kMIpVAiwVHkHTsNXiKLI+eNQ82NpdA4uBJq65HyiOVfDMcOIFgAgR8RHFwAAEAXSDQDyhHQDgDwh3QAgT0g3AMgT0g0A8oR0A4A8Id0AIE9INwDIE9INAPKEdAOAPBmn20ERAMBtQroBQJ6QbgCQJ5HSrSkrIaqy8S0vJGIpxFL0y9r1c9jWK3HcVlRF/SY3dNznRXuOVLDThlpP/4nsm0sGiz94JcMDbqnW8dBhi2pLRsx0W9Vb3/LObJ+KU5RIoTkjSaU+0Pr8Pt7qohJiVRSVEI/NcP9qKklrJhWl4KmmTY3OatEx4MJWov0acEk3xxDEFtaWjBjptq1X8nAmENog29arwEnqVMqjEKu6ftQ0rU0i+9mQ4AywnGf2U/CyE9QSW2ErU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mODsAYA8iZNuLk8e5+nkLPssX3z+wN0QJ912u+knEbt4eOU1+PkDd0O0K9Mr+YZnmWVpGe4G0f7bX4MOh1bSh5eEELppkW4IoTxFuiGE8hTphhDKUx7p9v5fKSoh1s37q38dpBtCKKx80u1P/bkSnzdb0g0hdH1KdGW6/fnLPsoj3RBCYZUk3RyuYUk3hFBYjdKt+VGd/nvIpRDL4uefdrPufvyxLsXx3XXz/npe32dWF2Hjzf/tB86xf6zDoX2uiuMTIL6vSTeEkK/GY7d+kPV3U4jTnNoptrq0Us19WnVrftV/x285jN32++a7KNf7tl/48EODELppGdJtmEembDKm23hzrVPR4dDu16XoIN0QQr5yH7uFSLfN2pRx57Hbc70g3RBC3tKmWzdHVm5epVmz88XpeH25eVXn3c6zbMd7R6Q9jHUeuy0evi2EWNRBbjRBCN2tdOkW6Ba2WeJvpgihsDL8zTR5wJFuCKGw4t+ZIoTyFOmGEMpTpBtCKE+RbgihPMX/+AcAeUK6AUCekG4AkCekGwDkCekGAHlCugFAnpBuAJAnpBsA5AnpBgB5QroBQJ6QbgCQJ/8DemCJ7YKaGnMAAAAASUVORK5CYII=" alt="" />

  很显然我的IDE用了红色波浪线表示这是个语法错误。

  那我这样写

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZ8AAABGCAIAAACcxg6QAAAGJklEQVR4nO2du5LbNhSGzyu5w7OkXz7GUk/AbtW73VHLFKmiSZ5BKThp7BkXShm7kBumoESBuBGUAErBft+c2ZGgn8DhBb8OsVxbegCAEpFHJwAAkAXcDQDKBHcDgDLB3QCgTHA3ACgT3A0AyiShu7VVLVJXbboe70c2IhsZXzvbl9A1Wxm2lVo1R3Ogoc+bes6UcNSGTs24R+HNDUFAnzwT/YAHso08dMiyyh5CanfbNl26Hru9uliJYZoLnNSYA/095+PYqFpkq1Qtsmv1/m1XMlpmI0vCc0P7Bl00YqTBpc3E+TUQ426RJogsrWxCt1dSi9on9Aonqdyta7ZmOZMIp5F1zTaxk0alshPZNs3OM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amrH0XeXtt3i92NpRyQxE3doK7lRJruFvgckSGbH1ZOHC3YoJ1N2QfTjbTCe5WSmQ5i/pXqC+QIVtZFnv1igjuVkSsuu6GDNkzyMKBuxUTuBuyDycLB+5WTKy67ua74JAhW1MWDtytmFivduutiw8ZsofIwoG7FRNruJvxdWpfc8iQrSkLB+5WTKx6Z4oM2TPIZjrB3UoJziJBTAJ3KyY4iwQxCdytmOAsEsQkcLdigrNIEJPA3YoJ/sc/ACgT3A0AygR3A4Aywd0AoEyWutuhklpk12ZJBgAgGUvd7dioWtS+y5IMAEAyMt6Zds2WKg8AHkU+d+MeFgAeibRVLeM/pCAb1Rz7dnd+W+0qGT7dtX1/bb961uEi0DafKA29Sdeo4eHJChcEgKTItcjq9krGNbWzbZ3d6opdkQ0t26YzPoqp3drqbGvjCwCANGjuNvEjnzf53M3YPNDDlLYSoXoDgPSEa7cU7tbu/B53Kdm6RuFuAJAUMdbOqtZcNbvenE7bq7a31920VbZjo2qzB5uhdlMvL0pENTxoAgCpuLgbj7ABQFlovzPF4ACgIPg7UwAoE9wNAMoEdwOAMsHdAKBMcDcAKBPcDQDKBHcDgDLB3QCgTHA3ACgT3A0AygR3A4Aywd0AoExwNwAok/8Aj1DCLalJ5HcAAAAASUVORK5CYII=" alt="" />

  \ 符号表示我这行代码写不下了,我要换行再写(这个符号和linux命令中的一样),其结果是:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAksAAAA0CAIAAAAVNOtoAAAIy0lEQVR4nO2dPbbzKAyGWZaXMBsJy3CKrx66VDM7cHvpswo33kE24SlsMCCBiQO+HvI+JycncWRJiB/xk9wr+j8KDzzwwAMPPNp7iBkAAABoEWQ4AAAAbYIMBwAAoE0+yHDTs+ue06cOjFL0Qgz6Uz0c1/fwHPQgCsShiK2X6tLBHOV+qHNkfoPcOBdvUUUDUq+1nNkOAZjnOZ7hlpHoLsRdyDEu81BOg9XS3CLu8o0Od6h/Ts9O9L4tx+e1I4UeHuVqQ2pO7XjC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O7ykMlw6RHzGFZVMDqzFlkHCnoY3MKaSPiWqZmWtKz1QJ7eHlObcBsyh2XqcbWSQqY9marErNqvt7grNvtKFVjDbfq8UTIRkcMZhR2aqdju210P8/2haYPmjHh+4g87WcdoQT62zstTW2lPIFNQph5XKylk2pOpSsykPSwT3vJMCOEeu/nncM495tK2XHOG5HVxeLt1q1xiqPV85YbdVNmMvKuT1R9oTptOeJjpVfo6dZvIaMn9PrJImsmwHsonNNP4Q6aGTD2uVlLItCdTlV9IqpRY1pkLRYSNciyNJeqpnoesCcERLJlLOZNtnZFPNF8aT1ypcaUeVysprrR3pSqXyHALtNhFYsEqsReFQ/Ape1dxD2O2YuZiSqhCtmilrNvXtPnmOAyZsjL1uFpJIdOeTFUulOEAAACAgiDDAQAAaBNkOAAAAG2CDAcAAKBNkOEAAAC0CTIcAACANkGGAwAA0CbIcAAAANoEGQ4AAECbIMMBAABoE2Q4AAAAbYIMBwAAoE2Q4QAAALQJMhwAAIA2QYYDAADQJshwAAAA2gQZDgAAQJsgwwEAAGiT/wCLyxdRdVEC6wAAAABJRU5ErkJggg==" alt="" />

  嗯……多了几个空格,那我再改改:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZQAAABHCAIAAACveibCAAAGBUlEQVR4nO2dvXLjNhSF7ytth2dJbz6GqSdgZ/XbetQyRapokmdQCk6a9cwWSrm7hd0wBSn+gAAIkgBl2N83Zzw2dQBcYYkjkKZnpQYASBC5dwEAAGsgvAAgSQgvAEgSwgsAkoTwAoAkIbwAIEnChleZ5SJ5VgbtdCNyEDlI973x+BKq4ihNW8lVcdUHavpc1XOkgr0aGj3dO3I31wwOf/BKhhPuqNZz6rBFtQUnQngdiypcj9VZ3ZJCy8QFQamd4vWW6b4WKhc5KpWLnMph/9PQ0Y7MKkrBc0PbBl00omd+ha3EmPI+4eWZcdjC2KqzklzUOWAstAOF66oqjvpmJBDGnKqKY+Cg9CrlJHIsipNhaGPQuP+xV+eRP44McsfTurh0pFLYSqY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5rNtSzO97E9jx9dyW6LmRH/F9fHS9tifEO7nAgAoJ5ePw4dVnM1Ib3pN7TUKe7HzDuX0JEzuSMSsJNwbnp/Imoo23c6bqX9CmdiWcJbtpV3V4VvdaFWnnLS6sf3T2qd3SvjM2ORAxnqm+fNZ1aNzH19et5Ug2V9Rn7ptj+MTwvNOAAClfOHfAwEAAPh1kI8BAADOh3wMAABwPv8Hzie4llFBy6IAAAAASUVORK5CYII=" alt="" />

  很好,空格是没了,然而,并没有什么卵用。

  不甘心啊,难道就没有解决方法了吗?此时,三个引号表示:孩子,你还太年轻。

a = '''scolia说:"我要说一句话,这句话很长长长长长长长长长长
长长长长长长长长长长长长长长长长长"'''
print a

  还是要注意单双引号的嵌套问题。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAccAAABHCAIAAAD9WRuJAAAI/0lEQVR4nO2dzZWjOhCFFRYhvESsMHAEo51X72XAtrV3FGzIwEnwFiCQVCUhiwLjnvudOT42XVSV/i6FcE+rEQAAgBzq7TOGZ9M8h71xe61apTq71w/H9TM8B9spgX4QifUyTb4ze73d1SU2n6C0n8VnlGiHHDdbzpyH1yBS1Wn235W6K90nTnmZ5mG8TrLanaLu+o1BrpoTw7NRbRjLy3kevDjDWq62jEtGJzDWdh4dbcfBPMpOrEzMDUeq0/Kd+TK3zYVXYnM+fts3kZ1RL9NIeXurFRfxfF0CVR3MozGvcRzHsdfpy4tnNs7G01wZnk120gzm6f20YoZ568p27rLfG5ezde5IhqXszvBACkdnZi0QllYc1hy/GBmejWJX0UmdGY7gsWeN47uF2OdnFN/SsBWSfXic5wsTqKpf4nktIVMhvsUuVNXIT8UM80+JTw+6vnITYH+Gx/EqHZ3ZmBaPBzUnLEZsp3SnmYr4nM6si1Kd27uF2Mdn1OZsSdlczfOlCVS1PHuro87y78rnj9pOFeVdqe5nfjP9Wxe5MQ+l7mtdOd/gT/Ix70PFNpMhqZdNaOBnaHWrVKd16/yckWEAc9bDDOFGW2BDeWduBQUCo6rrp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ZD3ABjZ7bMD3gtF9A7UFbGCz0wb8AjCQNSwLILMSYAObPTbge8Gg1nC1FQib32cDvhcMag3+YkgtDNjAZo8N+F4wojUot03mf4QNbARtwPeC4axBKRWtBBzBEdkj4HvBQNZQsgBgA5s9NuB7wegCAIAkUFUAAJAEqgoAAJJAVQEAQBKoKgAASAJVBQAASaCqAAAgCVQVAAAkgaoCAIAkUFUAAJAEqgoAAJJAVQEAQBKoKgAASAJVBQAASaCqAAAgCVQVAAAkgaoCAIAkUFUAAJAEqgoAAJJAVQEAQBKoKgAASPI/CWEqFNIFjCoAAAAASUVORK5CYII=" alt="" />

  一看运行结果,竟然成了,这可真魔法。

  这时,又有机智的人表示,三个引号不是注释的多行写法吗?为什么这里又能作为创建字符串的特殊符号,这样好混乱呀!

  其实分辨三个引号里面写的到底是注释还是字符串有一个绝佳的方法,就是看它前面有没有赋值给某个变量,看那标准的赋值符号(=)。如果有赋值,那就是创建了字符串对象,没有,那就是注释了。

  真是机智如我,这都被我发现了

   好了,关于引号的问题就先讲到这里。


4.字符串的序列特性

  都说字符串也是序列了,那么就可以用序列的方法去处理它了。

  所有序列类型都可以进行某些特定的操作。这些操作包括:索引(indexing)、分片(sliceing)、加(adding)、乘 (multiplying)以及检查某个元素是否属于序列的成员(成员资格)。除此之外,Python还有计算序列长度、找出最大元素和最小元素的内建函数。

   关于序列,以后会另起一篇进行说明,着急的话可以看看别人怎么写的先,或者你看我更新了后面的内容了没。


5.字符串的不可修改的

  字符串是无法修改的,一旦从内存中生成,就无法改动它,任何试图改变它的操作,例如:

a = 'scolia'
#我突然想将第一个s大写
a[0] = 'S' #用索引的方法修改

  其结果:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfoAAABTCAIAAAD4E1KMAAANCUlEQVR4nO2dzZHzuBGGEYVTcAoIwYkIWawmAuOm0zqC5dU4uMoHJrEq1zKCb5KADyRAAN0AwR9RHOF9ampKwyEajSb5CmxKaGE/lqG/6e93O9E2OAQAXAjxjk5N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RU5ErkJggg==" alt="" />

  很明显不能,那我这样写呢?

a = 'scolia'
a = 'Scolia'

   其实这样是等于重新赋值了,关于变量的赋值是怎么样的,可以看我之前的文章。

  实际上原来的值还在内存之中,只不过改变的a变量的引用,让其指向新的值,而旧的值并没有改变,只是在内存中等待python的垃圾回收。

  关于可修改和不可修改的数据类型,我后面也会有一个总结。


5.字符串的内建方法

  这些方法又是一堆,有些人可能会死记硬背,但是我建议在学会了面向对象后再来回顾这些内容,到时候会有一种顿悟的感觉。

  关于内建方法的总结又要另起一篇说明了,因为写到这里实在太长长长长了。

  突然之间觉得自己好像挖了很多的坑,现在容我先休息一下……

5.python的字符串的更多相关文章

  1. Python格式化字符串~转

    Python格式化字符串 在编写程序的过程中,经常需要进行格式化输出,每次用每次查.干脆就在这里整理一下,以便索引. 格式化操作符(%) "%"是Python风格的字符串格式化操作 ...

  2. python学习--字符串

    python的字符串类型为str 定义字符串可以用 ‘abc' , "abc", '''abc''' 查看str的帮助 在python提示符里 help(str) python基于 ...

  3. Python格式化字符串和转义字符

    地址:http://blog.chinaunix.net/uid-20794157-id-3038417.html Python格式化字符串的替代符以及含义     符   号     说     明 ...

  4. [转载] python 计算字符串长度

    本文转载自: http://www.sharejs.com/codes/python/4843 python 计算字符串长度,一个中文算两个字符,先转换成utf8,然后通过计算utf8的长度和len函 ...

  5. Python基础-字符串格式化_百分号方式_format方式

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  6. python判断字符串

    python判断字符串 s为字符串s.isalnum() 所有字符都是数字或者字母s.isalpha() 所有字符都是字母s.isdigit() 所有字符都是数字s.islower() 所有字符都是小 ...

  7. Python格式化字符串

    在编写程序的过程中,经常需要进行格式化输出,每次用每次查.干脆就在这里整理一下,以便索引. 格式化操作符(%) "%"是Python风格的字符串格式化操作符,非常类似C语言里的pr ...

  8. python(七)字符串格式化、生成器与迭代器

    字符串格式化 Python的字符串格式化有两种方式:百分号方式.format方式 1.百分号的方式 %[(name)][flags][width].[precision]typecode (name) ...

  9. Python 的字符串格式化和颜色控制

    (部分内容源自武神博客和网络收集.) Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两 ...

  10. python反转字符串(简单方法)及简单的文件操作示例

    Python反转字符串的最简单方法是用切片: >>> a=' >>> print a[::-1] 654321 切片介绍:切片操作符中的第一个数(冒号之前)表示切片 ...

随机推荐

  1. 海外支付:遍布全球的Paypal

    海外支付:遍布全球的Paypal 吴剑 2015-11-26 原创文章,转载必需注明出处:http://www.cnblogs.com/wu-jian 吴剑 http://www.cnblogs.co ...

  2. opencv基于HSV的肤色分割

    //函数功能:在HSV颜色空间对图像进行肤色模型分割 //输入:src-待处理的图像,imgout-输出图像 //返回值:返回一个iplimgae指针,指向处理后的结果 IplImage* SkinS ...

  3. 记录特殊情况的Python脚本的内存异常与处理

    问题 Python 脚本使用 requests 模块做 HTTP 请求,验证代理 IP 的可用性,速度等. 设定 HTTP 请求的 connect timeout 与 read response ti ...

  4. MSP430F149学习之路——按键与LED

    代码 /*********************************** 程序功能:用按键控制LED状态 缺点:按键按下后无法改变LED灯的状态,可以利用板上的复位键^~^ ********** ...

  5. bzoj1003 [ZJOI2006]物流运输

    1003: [ZJOI2006]物流运输 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 6300  Solved: 2597[Submit][Stat ...

  6. 华为OJ平台——百钱买百鸡问题

    题目描述: 元前五世纪,我国古代数学家张丘建在<算经>一书中提出了“百鸡问题”:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一. 百钱买百鸡,问鸡翁.鸡母.鸡雏各几何? 思路: 这道题很简单,假 ...

  7. TCP/IP详解学习笔记(14)-- TCP可靠传输的实现

    1.概述      为方便描述可靠传输原理,假定数据传输只在一个方向上进行,即A发送数据,B给出确认 2.以字节为单位的滑动窗口      TCP的滑动窗口是以字节为单位的.为了便于说明,字节编号取得 ...

  8. Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at offset 0

    在安装pcre-8.13.tar.gz时候出了错,说是缺少libpcre.so.0 下面是解决方法.真不容易哦,一个问题来没解决,新问题就出来了.一环扣一环,会搞死去.. errorgrep: err ...

  9. 二模09day2解题报告

    T1.domino骨牌 n张有黑有白的骨牌排一排,连续三张同色排一起就不好看,求共多少方案不好看. 分析一下,f[3]=2,f[4]=6,f[n]:如果n-1==n 那么方案数为f[n-2],如果不同 ...

  10. windows网络编程-2015.12.29

    在windows环境下,使用netstat命令查看网络状态,具体命令如下所示: netstat -ano | findstr listenport 在windows环境下,创建udp程序接收端,具体代 ...