Bottom Page

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
You like this post
Quote
#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
You like this post
Quote
#3
Could you tell me how to do that plz?
Quote
#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'))
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Creation of Dynamic HTML by substituting Database values Sandy777 1 276 Apr-18-2019, 07:17 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)