Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string.template
#3
Hey, this is my python code
if shape == "rectangle":
            x,y,w,h = cv2.boundingRect(c)
            cv2.rectangle(image,(x,y),(x+w,y+h),(0,255,0),0)
            from string import Template
            from string import Template
            def main():
                cordinates=[]
                cordinates.append(dict(abscisse=x,ordonee=y,width=w,height=h))
                t=Template("""
            x: $abscisse
            y: $ordonee
            w: $width
            h: $height
                           """)                
                print '    Rectangle:'
                print("      {")
                for data in cordinates:
                    print (t.substitute(data))
                    print("      }")
            if __name__=="__main__":                
                main()
and I'm not sure how to extract/generate a .qml file from it!
Thank u for ur help
Reply


Messages In This Thread
string.template - by Akhou - Apr-26-2018, 07:25 PM
RE: string.template - by Larz60+ - Apr-27-2018, 10:50 AM
RE: string.template - by Akhou - Apr-27-2018, 11:29 AM
RE: string.template - by Larz60+ - Apr-27-2018, 05:29 PM
RE: string.template - by nilamo - Apr-27-2018, 06:16 PM
RE: string.template - by Akhou - Apr-30-2018, 11:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  template string format specifiers VincentLamphier 3 7,481 Jan-13-2019, 07:47 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020