Here is my code.
import sys
import os
usersFile = open(sys.argv[1], "rb")
if not os.path.exists("recv"):
os.makedirs("recv")
copiedFile = open("recv/" + str(usersFile), "wb")
byteChunk = usersFile.read(1000)
while (byteChunk):
copiedFile.write(byteChunk)
byteChunk = usersFile.read(1000)
usersFile.close()
copiedFile.close()
This is in Python3, and the issue I am having is the file does get copied over byte by byte, and it is in the right directory, but the file is named <_io.BufferedReadername = 'Test.jpg'>
I just need it to be named Test.jpg which is the file I copied.
This program was called like this:
python3 programName.py Test.jpg
usersFile
is not a file name but an open file object. Replace str(usersFile)
with sys.argv[1]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.