Python Forum
Database Creation and Reading
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Creation and Reading
#1
Hi, so I don't know if this is a stupid question or an impossible question but I'd just like to know if you guys can help me. I've decided to start developing a read/write program that stores user info. I was wondering if you knew how to make a script that will ask for someone's name and then create a file with the same name as them? And yes there will be further questions on this subject so all information would be really helpful, thanks! (Oh, and I'm sorry if I posted this in the wrong category, I wasn't really sure) Big Grin Big Grin Big Grin
Reply
#2
Quote: I was wondering if you knew how to make a script that will ask for someone's name and then create a file with the same name as them?
Answer is yes
Reply
#3
Could you tell me how to do that plz?
Reply
#4
This is basic python, any tutorial will have you there probably within the first hour.
see: http://interactivepython.org/courselib/s...index.html
and: http://www.greenteapress.com/thinkpython...ython.html

Here's a simple example (untested) save as write_something.py:
def write_some_text(sometext, filename):
    with open(filename, 'w') as fp:
        fp.write(sometext)

write_some_text('Hey, what do you think about that', 'MyTextFile.txt')
you can run from command line with:
python write_something.py
To read back and print:
read_me.py:
def read_me(filename):
    with open(filename) as fp:
        read_text = fp.read()

print(read_me('MyTextFile.txt'))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading blob data from database by python and store it in .zip format Adityasi 2 6,443 Nov-18-2019, 05:22 PM
Last Post: ibreeden
  Creation of Dynamic HTML by substituting Database values Sandy777 1 2,101 Apr-18-2019, 07:17 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020