0

I'm trying to create a script that will create sequential file names for images in a directory with leading zeros. The current code I'm trying to use is:

####Take a picture.
filename='/home/pi/pictures/'print 'img_{0:05d}'.format(i)'.jpg'
self.shoot(filename=filename)

I'm getting a syntax error when running seen here below. http://prnt.sc/dhpf51

3
  • The print is outside the quotes and there is no connector to the string before it. And there's no need to put print in there at all. The rest is fine. Commented Dec 10, 2016 at 15:01
  • 1
    '../pictures/img_{0:05d}.jpg'.format(i) Commented Dec 10, 2016 at 15:09
  • Please don't post screenshots (or links to screenshots) of text, paste the actual text into your question; you can use a code block to preserve formatting. See Why may I not upload images of code on SO when asking a question?. Commented Dec 10, 2016 at 15:14

1 Answer 1

1

As the screenshot,

filename='/home/pi/pictures/'print 'img_{0:05d}'.format(i)'.jpg'

is not correct syntaxt, you placed the print keyword between format string, you can just use format for creating the path string.

filename='/home/pi/pictures/img_{0:05d}.jpg'.format(i)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.