Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python print file

import sys

# only this print call will write in the file
print("Hello Python!", file=open('output.txt','a'))

# not this one (std output)
print("Not written")

# any further print will be done in the file
sys.stdout = open('output.txt','wt')
print("Hello Python!")
Comment

print file in python

GHOSTSCRIPT_PATH = "C:path	oGHOSTSCRIPTingswin32.exe"
GSPRINT_PATH = "C:path	oGSPRINTgsprint.exe"

# YOU CAN PUT HERE THE NAME OF YOUR SPECIFIC PRINTER INSTEAD OF DEFAULT
currentprinter = win32print.GetDefaultPrinter()

win32api.ShellExecute(0, 'open', GSPRINT_PATH, '-ghostscript "'+GHOSTSCRIPT_PATH+'" -printer "'+currentprinter+'" "PDFFile.pdf"', '.', 0)
Comment

PREVIOUS NEXT
Code Example
Python :: imshow of matplotlib 
Python :: how to get list size python 
Python :: vector data 
Python :: WARNING: Ignoring invalid distribution c program files python39libsite-packages 
Python :: @ in python 
Python :: Maximum sum subarray of size ‘K’ 
Python :: sort dataframe by function 
Python :: handling exceptions 
Python :: how to slice list 
Python :: .sort python 
Python :: array sort in python 
Python :: removing value from list python 
Python :: np where and 
Python :: swap list 
Python :: Python RegEx SubString – re.sub() Syntax 
Python :: for _ in range() in python 
Python :: master python 
Python :: python try except print error 
Python :: minmax python 
Python :: numpy array into tuple 
Python :: pack() tkinter 
Python :: mod in python 
Python :: what is an indefinite loop 
Python :: django.core.exceptions.ImproperlyConfigured: Field name is not valid for model 
Python :: punto1 
Python :: multiprocessing write to dict 
Python :: Change UI within same window PyQt 
Python :: how to test webhook in python.py 
Python :: Define the learnable resizer utilities 
Python :: folium add a polygon to a map 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =