当前位置:   article > 正文

python实时读plc数据_Python读取实时数据流示例

python读取贝加莱plc数据

1、#coding:utf-8

chose = [

('foo',1,2),

('bar','hello'),

('foo',3,4)

]

def do_foo(x,y):

print('foo',x,y)

def do_bar(s):

print('bar',s)

for tag,*args in chose:

if tag == 'foo':

do_foo(*args)

elif tag == 'bar':

do_bar(*args)

line = 'nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false'

uname,*fields,homedir,sh = line.split(':')

print(sh)

from collections import deque

def search(lines, pattern, history=5):

previous_lines = deque(maxlen=history)

for li in lines:

if pattern in li:

yield li, previous_lines

previous_lines.append(li)

# Example use on a file

if __name__ == '__main__':

with open(r'./somefiles.py') as f:

for li

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/80970
推荐阅读
相关标签
  

闽ICP备14008679号