Forum: Poser Python Scripting


Subject: Py2 to Py3 conversions

structure opened this issue on Nov 08, 2020 ยท 6 posts


adp001 posted Sun, 08 November 2020 at 10:52 AM

The standard Python way works fine for file writing:

with open("test.txt", "w") as fh:
    for idx in range(10):
        print(f"Line {idx}: Test", file=fh)  # The 'f' prefix means: format, Py3 only.

with open("test2.txt", "w") as fh:
    for idx in range(10):
        fh.write(f"Line {idx}: Test\n")