有限状态自动机例题python
时间: 2023-09-26 14:08:12 浏览: 59
下面是一个使用Python实现的有限状态自动机的例题:
```python
# 创建状态类
class State:
def __init__(self, i):
self.i = i
def tran(self, ss, fsm):
pass
# 创建有限状态机类
class Fsm:
def __init__(self, state, pattern):
self.state = state
self.pattern = pattern
def trans(self, ss):
print("当前状态:", self.state.i)
self.state = self.state.tran(ss, self)
print("转换后状态:", self.state.i)
# 创建状态转移规则类
class Rule:
def __init__(self, current_state, input, target_state):
self.current_state = current_state
self.input = input
self.target_state = target_state
#### 引用[.reference_title]
- *1* *3* [有限自动机可解析数据例题分析](https://blog.csdn.net/HLComet_Bay_WC/article/details/114994037)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [有限状态机详解与举例(leetcode 1023)](https://blog.csdn.net/lady_killer9/article/details/120634447)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)