The file contents won't get updated after you call add()
.
See the below code:
import tarfile
fp1 = open("hello.txt", "w")
tar = tarfile.open("myArchive.tar", "w")
tar.add("hello.txt")
fp1.write("Test String")
fp1.close()
tar.close()
After this is executed, 'hello.txt' will have "Test String", but the 'hello.txt' inside 'myArchive.tar' will be empty.