python - 我想用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 ' )
这个想法是从用户那里获取数据并从数据库中写入,但我真的被困在这里而且我是一个初学者。如果我通过这部分,我会尝试其他部分。
感谢您阅读和帮助我:)
解决方案
推荐阅读
- c# - C# 绘制矩形
- python - 我正在尝试使用 xlsxwriter 将数据抓取到 .xls 文件中,但它自己将数据写入工作表 5 次而不是一次
- react-native - TSlint 没有正确处理 React Native Redux 组件
- wso2-am - WSO2 APIM 提供 HTTP 状态代码 429 - 请求过多
- php - 递归显示嵌套的 XML 和属性 PHP
- python - Python3 上 Pymongo 的 SSL 握手问题
- php - 如何检查我是否在 WooCommerce 的类别概览页面?
- node.js - Node js堆检查器中的全局句柄和GC根是什么?
- git - 有没有办法 git clone 到提交(url)
- python - 填写groupby的缺失日期