Again, when you say something is not working properly, it isn’t clear what
your result is (error, or new second line not printing at all, or second
print not printing on a new line). I am just going to assume you mean it
didn’t print on its own new line…
“\n” and “\t” are special characters (as opposed to commands). The newline
character is platform specific, and on Windows you probably want “\r\n”.
Python gives you a platform independent way to do it. Give this a try and
see if it fixes your problem?
import os
...# platform specific line separator command via os.linesep
file.write("i am line 1" + os.linesep)
Also, if you want to clean up your snippet a bit, you could write it like
this:
import osimport maya.cmds as cmds
path=cmds.internalVar(upd=True)+"preset.txt"with open(path, 'w') as f:
f.write("i am line 1" + os.linesep)
f.write("i am line 2")
On Thu, Jun 4, 2015 at 4:09 PM Sumant Shenoy <[email protected]>
wrote:
> ah sorry for not being clear what i am trying to do is save preset .so
> read all the values from option box and check boxes and save it to the
> notpad file the "/n"
> command is what i found online to type it in the next line and "/t" is is
> the tab command on the keyboard for indentation
>
> so when i run the comand it should do the following things
> create a note pad file in the user pref dir called preset
> open the file in write mode
> type "i am line 1" (go to next line)
> type "i am line 2 "
> close file
>
> but in my case every thing is happening properly except for the type in
> the next line part
> hope i am clear this time
> Thank you for your time
>
> On Thu, Jun 4, 2015 at 12:47 PM, Justin Israel <[email protected]>
> wrote:
>
>> I don't know what this means. What do you mean by "printing this out in
>> note pad" and "not working" and "other commands like \t"?
>>
>> Please be very specific about what exactly you are trying to do, what you
>> expect, and what exactly the results were.
>>
>> On Thu, 4 Jun 2015 3:30 PM Sumant Shenoy <[email protected]> wrote:
>>
>>> ok i am trying to print this out in note pad line by line but but for
>>> some reason "\n"is not working am i doing some thing wrong because all the
>>> other commands like "\t" are working
>>>
>>> import maya.cmds as cmds
>>> path=cmds.internalVar(upd=True)+"preset.txt"
>>> file=open(path,'w')
>>> file.write("i am line 1"+"\n")
>>> file.write("i am line 2")
>>> file.close()
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CAGhqNnn75f%3DBRq6aQV34fZWE0MCraOxHrXWYxFwjSVqOnXZ%2BjA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAGhqNnn75f%3DBRq6aQV34fZWE0MCraOxHrXWYxFwjSVqOnXZ%2BjA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>>
> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3Auaciu%3DppT0JS%3DBShTbMvejtVHsJBrHiQoYJ0OHQcAQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3Auaciu%3DppT0JS%3DBShTbMvejtVHsJBrHiQoYJ0OHQcAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>
>
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAGhqNn%3DcPKmR7a7QzosX3aityqMhYSX%2Bj-vZm3wyVCtv1mVNHA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAGhqNn%3DcPKmR7a7QzosX3aityqMhYSX%2Bj-vZm3wyVCtv1mVNHA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA24GcR4m1kgVALjRYMOt488E1wr1JnHa%2B9W%3DOO151hffw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.