您现在的位置是:主页 > news > 崇明集团网站建设/自己怎么制作网站
崇明集团网站建设/自己怎么制作网站
admin2025/5/29 17:36:42【news】
简介崇明集团网站建设,自己怎么制作网站,广州微网站建设价位,三丰云做网站教程python的socket库可以实现tcp和udp,在linux下unix socket也是可以的,有些程序在进程间通信就是使用unix socket,如果我们想查看其通信的信息来进行调试,则可以用python来伪造其接口,获取内容import socketimport osif …
python的socket库可以实现tcp和udp,在linux下unix socket也是可以的,有些程序在进程间通信就是使用unix socket,如果我们想查看其通信的信息来进行调试,则可以用python来伪造其接口,获取内容
import socket
import os
if __name__ == '__main__':
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
if os.path.exists('/tmp/UNIX.d'):
os.unlink('/tmp/UNIX.d')
sock.bind('/var/run/rrdcached.sock')
sock.listen(5)
while True:
connection,address = sock.accept()
print "Data : %s"%connection.recv(1024)
#connection.send("hello")
connection.close()
参考:http://www.2cto.com/os/201305/210033.html
bash下字符串操作:
支持${parameter:offset:length},${parameter:offset}
igi@gentoo ~/test $ string='hello'
igi@gentoo ~/test $ echo ${string:1:3}
ell
igi@gentoo ~/test $ echo ${string:1}
ello
igi@gentoo ~/test $ echo $0
/bin/bash
dash: 不支持, 替代方法:采用expr或cut外部命令代替
$ string='hello'
$ expr substr "$string" 2 3
ell
$ echo "$string" | cut -c2-4
ell
$ expr substr "$string" 2 "${#string}"
ello
$ echo "$string" | cut -c2-
ello
$ echo $0
dash
$