搭建网站架构是什么意思,物流网站建设方案权限管理,如皋市建设局网站在哪,宁波seo推广优化公司6-12.字符串。#xff08;a#xff09;创建一个名字为findchr()的函数#xff0c;函数声明如下。def findchr(string, char)findchr()要在字符串string中查找字符char#xff0c;找到就返回该值得索引#xff0c;否则返回-1。不能用string.*find()或者string.*index()函数…6-12.字符串。a创建一个名字为findchr()的函数函数声明如下。def findchr(string, char)findchr()要在字符串string中查找字符char找到就返回该值得索引否则返回-1。不能用string.*find()或者string.*index()函数和方法。b创建另一个叫rfindchr()的函数查找字符char最后一次出现的位置。它跟findchr()工作类似不过它是从字符串的最后开始向前查找的。c创建第三个函数名字叫subchr()声明如下。def subchr(string, origchar, newchar)subchr()跟findchr()类似不同的是如果找到匹配的字符就用新的字符替换原先字符。返回修改后的字符串。【答案】a代码如下def findchr(string, char): a string k index -1 for i in a: k k 1 if i char: index k print index if index -1: print index , index a raw_input(Please input a string ... )b raw_input(Please input a character to be find in this string ... )findchr(a, b) b代码如下def rfindchr(string, char): a string k index -1 for i in a: k k 1 if i char: index k print index if index -1: print index , index a raw_input(Please input a string ... )b raw_input(Please input a character to be find in this string ... )rfindchr(a, b) c代码如下def subchr(string, origchar, newchar): output for i in origchar: if i string: output output newchar else: output output i print output subchr(c, abcddfasdfddacda, k) 以上源自 http://www.cnblogs.com/balian/archive/2011/05/31/2064213.html转载于:https://www.cnblogs.com/Kaivenblog/p/4636050.html