3 Respuestas
+ 1
hmm, I know what each of those words mean individually but I'm not sure what it means together:
compress: make a file smaller (often by removing extra spaces and other data that isn't as useful or saving in a different way that doesn't use as many bytes)
text file: a standard file with text inside - includes HTML or other other formats that save as text, as well as just people's writing that is saved as a .text file
user: person who uses or will be using the app or script
maybe it means to compress a text file that contains multiple sentences that a user has typed in.
+ 1
the tricky bit is the compression
one solution roughly is: make a new file that will be the compressed version, and then loop through reading sections of the non-compressed file, assessing each section for ways to compress it (maybe use the format function or one of the regex functions in the re library) and then write that now hopefully compressed section to the end of the new file, until the file ends.
Since it's user written data, you'll have to make allowances for unusual characters such as those with accents such as é, î, õ and ã and other characters like ¢£@"\¥©℅€
To solve this problem, I would use a rapid prototyping method of development - basically I mean run your code frequently and just code little improvements until you get the full solution.
So start by coding just read a file section by section with just a print to show each section, then run that, check it works as expected, and then get it writing to a file as it goes, run it check the file is the same, then add an attempt at compressing sections that are easy to compress, test it improve the compression/fix bugs and so on until you have the full solution
0
It does! Im not to sure how to code that 😢