首页 > 解决方案 > 我想用python制作基本的房地产脚本

问题描述

首先我想创建房地产脚本,所以它应该有菜单。首先它会询问你想在脚本中做什么。

我创建了这个菜单:

menu = 0

while menu != 6:
    try:
        answer = str(menu)

        menu = int(input(To buy house press 1\n To sell house press 2  , \n To list your house press 3,  \n for exit press 4 " "\n"))
    except(SyntaxError,NameError):
        print ("Enter correct numbers")

我知道这很简单,我需要一些想法来改进它。然后我想创建第一个菜单,但我被困在如何正确使用数据库上。我想给你看第二个菜单,因为它对我来说更重要。

第二个菜单:

  if menu == 2:
    cursor=connectdb.cursor()

    def create table():
        cursor.execute(
        CREATE TABLE newhouse(
        m_square INTEGER NOT NULL,
        room_number INTEGER NOT NULL ,
        place INTEGER NOT NULL,
        house_cost INTEGER NOT NULL
        )
        );
        con.close()

        m2 = input ('How many square meters is your home?  ' "\n" )
        room = input ('Enter the number of rooms of your home ' "\n" )
        floor = input ('On which floor is your house? ' "\n")
        price = input ('Enter the sales price of your home  '  )

这个想法是从用户那里获取数据并从数据库中写入,但我真的被困在这里而且我是一个初学者。如果我通过这部分,我会尝试其他部分。

感谢您阅读和帮助我:)

标签: pythonsqlite

解决方案


推荐阅读