标签:har 数据结构 初始 bsp 编程 ase 赋值 elf mys
创建类:
class MyString():
初始化赋值:
# def __init__(self,engishstr): # self.mystr = engishstr
简单的一个面向对象实列:
# def show_counts(self): # len_word = len(self.mystr) # print(len_word) # def show_char_counts(self): # word = self.mystr # len_word = len(self.mystr) # word_count = word.count(" ") # print(len_word - word_count) # def show_cap(self): # word = self.mystr # word_upper = word.upper() # print(word_upper) # def show_word_counts(self): # word = self.mystr # word_split = word.split(" ") # len_word = len(word_split) # print(len_word) # def show_last_word_len(self): # word = self.mystr # word_split = word.split(" ") # word_len = len(word_split[-1]) # print(word_len) # def show_long_word(self): # word = self.mystr # word_split = word.split(" ") # max_word = word_split[0] # for x in word_split: # if len(x)>len(max_word): # max_word = x # print("最长单词为%s,长度位%d" % (max_word,len(max_word)))
标签:har 数据结构 初始 bsp 编程 ase 赋值 elf mys
原文地址:https://www.cnblogs.com/J-xiaowei/p/11408851.html