class MyString:
def __init__(self, myString):
self.__myString = myString
def countWord(self):
count = len(self.__myString.split())
return count
def findMostFrequentChar(self):
# ?
Run Code Online (Sandbox Code Playgroud)
我需要实施findMostFrequenctChar.她给我们的唯一暗示是我们需要制作2个名单.这就是她失去我的地方.
这是调用函数的代码:
def main():
aString = MyString("This is a super long long long string. Please help count me")
print("There are", aString.countWord(), "words in the string.")
count, letter = aString.findMostFrequentChar()
print("The most frequent character is", letter, "which appeared", count, "times")
main()
Run Code Online (Sandbox Code Playgroud) 应用程序
from flask import Flask,request
from flask_restful import Api , Resource
from flask_jwt import JWT ,jwt_required , current_identity
from security import auntheticate , identity
app = Flask(__name__)
app.secret_key = "sangam"
api = Api(app)
jwt = JWT(app,auntheticate,identity)
items = []
class Item(Resource):
@jwt_required
def get(self,nam):
item = next(filter(lambda x:x['name'] == nam, items), None)
return {'item':item} ,200 if item else 404
def post(self,nam):
if next(filter(lambda x:x['name'] == nam,items),None):
return{'message':"an item with name '{}' already exist." .format(nam)}
data = request.get_json()
item = {'name':nam, …Run Code Online (Sandbox Code Playgroud)