Python ftplib: Show FTP upload progress

前端 未结 1 1404
谎友^
谎友^ 2020-12-30 12:03

I am uploading a large file with FTP using Python 3.4.

I would like to be able to show the progress percentage while uploading the file. Here\'s my code:



        
1条回答
  •  一整个雨季
    2020-12-30 12:26

    There are three non-hacky ways I can think of. All of then shift the "ownwership" of the variable:

    1. have the value passed in and return the result (basically means its stored in the caller)
    2. have the value be global, and initialize it to 0 and the top of your file. (read up on the global keyword)
    3. have this function as a member function of a class to handle upload tracking. Then make sizeWritten a instance variable of that class.

    0 讨论(0)
提交回复
热议问题