##  pip install hdfs
from hdfs.client import Client

# 覆盖数据写到hdfs文件
def write_to_hdfs(client, hdfs_path, data):
    client.write(hdfs_path, data, overwrite=True, append=False, encoding='utf-8')



# 从hdfs获取文件到本地
def get_from_hdfs(client, hdfs_path, srcPath):
    client.download(hdfs_path, srcPath, overwrite=False)


# 删除hdfs文件
def delete_hdfs_file(client, hdfs_path):
    client.delete(hdfs_path)

# 上传
def upload(srcPath, hdfs_path):
    client.upload(hdfs_path, srcPath, cleanup=True)
    
if __name__ == '__main__':
    client = Client("http://slave01:50070/",root="/",timeout=10000,session=False)
    upload("D:/mysql-connector-java-5.1.46.jar", "/")
    
    pass

 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: Hadoop