Jan-19-2017, 03:07 PM
I'm not near the linux machine at the moment, but tried on the windows 10:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import subprocess import colorama as cr print("Some text in default color.") cr.init() # Needed for Windows, supposedly ignored by linux print(cr.Fore.GREEN) subprocess.run("dir", shell=True) print(cr.Style.RESET_ALL) print("Hopefully some text in default color, again.")Output:
Output:C:\Python\scratch.py
Some text in default color. # Default color
# This is in Green
Volume in drive C is Acer
Volume Serial Number is 8CE3-7690
Directory of C:\Python\
01/19/2017 09:54 <DIR> .
01/19/2017 09:54 <DIR> ..
01/19/2017 09:54 479 scratch.py
1 File(s) 479 bytes
2 Dir(s) 907,242,061,824 bytes free
Hopefully some text in default color, again. #Back to default color
C:\Python\>
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition