QuestionExporting a Txt File

Posts 18 of 8 · Page 1 of 1
Exporting a Txt File
Hi guys I was making a little script that makes a .txt and then records the information and uploads on a cloud or my pc for a quiz. I was wondering if someone could help me by showing me how to make that .txt upload onto my med iaf re or d ropb ox, etc...

OR if that isnt possible have it directly upload to my pc.

Using Python btw
With php you can use the fopen() function to write data to a document. I think it's pretty similar in python aswell.

example code:

f = open("yourfile.txt", "w") # yourfile.txt = the document you want to write to, "w" tells python to write
f.write("hello") # text to write
f.close() # close
hope this helped ya, not entirely sure if that code will work but give it a try.
Quote Originally Posted by griimnak View Post
With php you can use the fopen() function to write data to a document. I think it's pretty similar in python aswell.

example code:


hope this helped ya, not entirely sure if that code will work but give it a try.
I know how to write a file, but I needed it to go onto a website or online. Something in that concern. But Thanks!
Quote Originally Posted by Ffrocks3 View Post
I know how to write a file, but I needed it to go onto a website or online. Something in that concern. But Thanks!
Ah I see, so maybe sending it to your gmail account? that can be done with smtp connection:
Code:
import smtplib as server
connect = server.SMTP("smtp.gmail.com:587")
		connect.starttls()
		connect.login('usernamehere', 'passwordhere')

connect.sendmail('usernamehere', 'targetemail', and here you can write the contents of your txt as the message)
Quote Originally Posted by griimnak View Post
Ah I see, so maybe sending it to your gmail account? that can be done with smtp connection:
Code:
import smtplib as server
connect = server.SMTP("smtp.gmail.com:587")
		connect.starttls()
		connect.login('usernamehere', 'passwordhere')

connect.sendmail('usernamehere', 'targetemail', and here you can write the contents of your txt as the message)
So would I be able to set this up so it auto sends to my gmail from the .txt file it's creating? Like when the; lets say "quiz" is done it will send to it?
Because currently it gets the answers and then makes a .txt in the folder the file is in. Then I wanted it to send.
Quote Originally Posted by Ffrocks3 View Post
So would I be able to set this up so it auto sends to my gmail from the .txt file it's creating? Like when the; lets say "quiz" is done it will send to it?
Because currently it gets the answers and then makes a .txt in the folder the file is in. Then I wanted it to send.
mmm, not exactly sure but you could set a python timer so it uploads every x minutes/seconds/hours.
Give it a google bro i'm sure you'll find some usefull info, cheers
Quote Originally Posted by griimnak View Post
mmm, not exactly sure but you could set a python timer so it uploads every x minutes/seconds/hours.
Give it a google bro i'm sure you'll find some usefull info, cheers
Yea I can do that, Thanks Man! +rep appreciate it.
Quote Originally Posted by Ffrocks3 View Post
Yea I can do that, Thanks Man! +rep appreciate it.
cheers man
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?