adding characters to an input file name

1 week ago 14
ARTICLE AD BOX

I was wondering how to add to a file name. So, I have a file called test.jpgand I want the output to be my_test.jpg. I cannibalized and wrote the following code:

import argparse, sys def get_image_argument(): parser = argparse.ArgumentParser( description="Please specify a image file'." ) parser.add_argument( "-i", "--file", help="Please use -h or --help to see usage.", dest="image" ) argument = parser.parse_args() if not argument.image: print("[-] Please specify an image file. Use --help to see usage.") sys.exit() # Exit the program return argument image_args = get_image_argument() print(image_args) my_image = f"my_{image_args}" print(my_image)

However my image does not appear to be my_test.jpg when I use: python script.py -i test.jpg`.

How do I get this to work here?

Read Entire Article