python print to file w3 code example Example: python write with open(filename,"w") as f: f.write('Hello World')