“File cetak Python” Kode Jawaban

File cetak Python

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!")
VasteMonde

cara menulis ke file output di pytion

#first arg is the name of the file
#second arg notes that the file is open to write to it
outputFile = open("fileName", "w")
#next line writes to the file
outputFile.write(str)
#remember to close opened files
outputFile.close()
NitroPog

Python membuka dan membaca file dengan

with open('pagehead.section.htm','r') as f:
    output = f.read()
Good Goshawk

dengan terbuka sebagai python file

>>> with open('workfile') as f:
...     read_data = f.read()

>>> # We can check that the file has been automatically closed.
>>> f.closed
True
Powerful Platypus

cetak file dalam python

GHOSTSCRIPT_PATH = "C:\\path\\to\\GHOSTSCRIPT\\bin\\gswin32.exe"
GSPRINT_PATH = "C:\\path\\to\\GSPRINT\\gsprint.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)
Iniyan V

Jawaban yang mirip dengan “File cetak Python”

Pertanyaan yang mirip dengan “File cetak Python”

Lebih banyak jawaban terkait untuk “File cetak Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya