我正在通过机器人框架传递一个参数。参数是一个字符串。“底特律”。我希望代码将该字符串分解为“D”、“De”、“Det”、“Detr”、“Detro”、“Detroi”和“Detroit”。当然,如果输入另一个字符串,比如“Flint”,它只会将其分解为 5 个元素。F、Fl、Fli、Flin、Flint。
(伪代码)
def checkCity (self, x):
(take x which is the string, and make it a list of elements containing the letters as above).
(Then take each element and check it against data provided by the device(using a loop for each iteration)
(Once any of the elements are matched to the data, return another function that acts as a key press)
我对python(和编程)足够熟悉,一般都有理论,只是不知道如何编码。