2023年7月15日发(作者:)
python实现socket通信传输字符串_python之socket实现unixsock。。。python的socket库可以实现tcp和udp,在linux下unix socket也是可以的,有些程序在进程间通信就是使⽤unix socket,如果我们想查看其通信的信息来进⾏调试,则可以⽤python来伪造其接⼝,获取内容import socketimport osif __name__ == '__main__':sock = (_UNIX, _STREAM)if ('/tmp/UNIX.d'):('/tmp/UNIX.d')('/var/run/')(5)while True:connection,address = ()print "Data : %s"%(1024)#("hello")()参考:/os/201305/sh下字符串操作:⽀持${parameter:offset:length},${parameter:offset}igi@gentoo ~/test $ string='hello'igi@gentoo ~/test $ echo ${string:1:3}elligi@gentoo ~/test $ echo ${string:1}elloigi@gentoo ~/test $ echo $0/bin/bashdash: 不⽀持, 替代⽅法:采⽤expr或cut外部命令代替$ string='hello'$ expr substr "$string" 2 3ell$ echo "$string" | cut -c2-4ell$ expr substr "$string" 2 "${#string}"ello$ echo "$string" | cut -c2-ello$ echo $0dash$
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689408217a243242.html
评论列表(0条)