Why does this work in the "Python Shell" but when I execute it in a script it doesn't work?
day = time.strftime('%d', time.gmtime(time.time()))
When I execute this in a script i get this error:
Traceback(most recent call last):
File "Myfile.py"
day = time.strftime('%d'...
I tried to get access to a MySQL database like this:
import MySQLdb
db = MySQLdb.connect(db = 'mydb', user = 'user', passwd = 'password')
I get this error:
Traceback (most recent call last):
File "Myfile.py", line 3, in ?
db = MySQLdb.connect(db = 'mydb', user = 'user'...
Thanks, this works. Another question. How can i write a newline at the end of the line to the file?
I tried it like this:
for key, value in table.items():
f1.write(str(key) + ':' + str(value))
f1.write('\n')
But this doesn't work...
Your message was:
Without looking at my notes, I think you are going to have to do something like:
for x in table1
f1.write(table1[x])
or something along those lines.
I tried this:
for x in table1:
f1.write(table1[x])
but this doesn't work. I get this error:
Traceback (innermost...
Thanks. But now I have another problem. I've got a variable called "table1" in my program and i want to write the information of this variable to this new created file. This variable's type is a dictionary. I tried to write the information of "table1" into the file like...
I'm new to python and I've got a problem. In a python progamm I want to create a new file to write text into it. How can I create a new File in python? I've searched in the documentation but I found nothing. I've tried it with open and fopen but it didn't work. Can someone help me please?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.