零件清单数组
a =list(["CPU,$150.00","RAM ,$120.00","DVD drive $89.00","Hard Disk Drive,$189.99"])
for letter in a:
print(letter)
这是我的零件清单我试图弄清楚如何让它打印到打印机的任何提示
答案 0 :(得分:1)
来自python窗口print tutorial:
import win32api
import win32print
def parts_list():
a = ["CPU,$150.00","RAM ,$120.00","DVD drive $89.00","Hard Disk Drive,$189.99"]
with open('printfile.txt', 'w') as f:
for line in a:
f.write(line)
print_windows('printfile.txt')
def print_windows(filename):
win32api.ShellExecute(0, "print", filename, '/d:"%s"' % winn32print.GetDefaultPrinter (),".", 0)
def main():
parts_list()
if __name__ == '__main__':
main()