Python项目8:使用XML-RPC进行文件共享

本文通过Python的XML-RPC技术,演示了如何实现在不同目录间共享文件。具体操作包括:创建files1和files2文件夹,files1的urlfile.txt设置为http://localhost:4243,files2的urlfile.txt设置为http://localhost:4242,并在files2中创建testfile.txt。启动两个控制台,分别运行client.py,通过fetch命令实现files2的testfile.txt被复制到files1。
摘要由CSDN通过智能技术生成

代码地址:https://code.csdn.net/ranky2009/pythonsmallproject

Python版本:3.4.3

操作系统:win7
本项目是分析python基础教程(第二版)项目8:使用XML-RPC进行文件共享
SimpleXMLRPCServer的python3与python2所在库不一样,对原教材上代码略作修改,就可以运行在win7中

代码如下:

1.    client.py

from cmd import Cmd
from os import path
from random import choice
from string import ascii_lowercase
from server import Node, UNHANDLED
from threading import Thread
from time import sleep
from xmlrpc.client import ServerProxy, Fault
import sys

HEAD_START = 0.1 # Seconds
SECRET_LENGTH = 100

def randomString(length):
    chars = []
    letters = ascii_lowercase[:26]
    while length > 0:
        length -= 1
        chars.append(choice(letters))
    return ''.join(cha
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值