Apr-26-2018, 07:25 PM
Hello,
Is it possible to generate a .qml file using string.template?
Thank u ^^
Is it possible to generate a .qml file using string.template?
Thank u ^^
string.template
|
Apr-26-2018, 07:25 PM
Hello,
Is it possible to generate a .qml file using string.template? Thank u ^^
Apr-27-2018, 10:50 AM
you would need more than one print format, but so long as you choose the proper template to match your variables, I don't see why not.
There are better ways to do this. You'd be better off using something like PLY (python Lex-Yacc subs): http://www.dabeaz.com/ply/
Apr-27-2018, 11:29 AM
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
Apr-27-2018, 05:29 PM
this is not a snippet that can be run, so hard to analyze.
Apr-27-2018, 06:16 PM
if __name__ == "__main__": shouldn't be nested inside another block, and there's really no reason here for a function to be nested in that block, either.
Apr-30-2018, 11:33 PM
Thank u guys
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
template string format specifiers | VincentLamphier | 3 | 8,569 |
Jan-13-2019, 07:47 AM Last Post: snippsat |