git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# String slices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On 8/9/19 10:13 AM, Paul St George wrote: > In the code (below) I want a new line like this: > > Plane rotation X: 0.0 > Plane rotation Y: 0.0 > Plane rotation Z: 0.0 > > But not like this: > > Plane rotation X: > 0.0 > Plane rotation Y: > 0.0 > Plane rotation Z: > 0.0 > > Is it possible? > (I am using Python 3.5 within Blender.) > > # > import os > > outstream = open(os.path.splitext(bpy.data.filepath)[0] + ".txt",'w') > > print( > > "Plane rotation X:",bpy.data.objects["Plane"].rotation_euler[0], > > "Plane rotation Y:",bpy.data.objects["Plane"].rotation_euler[1], > > "Plane rotation Z:",bpy.data.objects["Plane"].rotation_euler[2], > > file=outstream, sep="\n" > > ) > > outstream.close() > Use separate calls to print: with open(...) as outstream: plane = bpy.data.objects["Plane"] print("X:", plane.rotation_euler[0]) print("Y:", plane.rotation_euler[1]) # print Z here And please (a) use "with" instead of "open" and "close," and (b) use an email client that preserves indentation.

- Prev by Date:
**String slices** - Next by Date:
**String slices** - Previous by thread:
**String slices** - Next by thread:
**String slices** - Index(es):