charlescwj 最近的时间轴更新
charlescwj

charlescwj

V2EX 第 152375 号会员,加入于 2015-12-21 21:21:22 +08:00
charlescwj 最近回复了
写在
自己来回复一下:明白问题出在哪里了 就是 我在创建和阻塞进程池的时候 卸载了循环内 应该卸载循环外才对
@John60676 大神 能帮我看一下这个问题吗?
2018-05-04 22:39:05 +08:00
回复了 Terry05 创建的主题 程序员 有没有跨浏览器的收藏夹插件?
xmarks 马上要关闭了 所以我切换到 eversync 了 也不错
2018-04-16 09:18:01 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676 您好 我还想问一下 按照我的理解 各个进程之间是相互独立的,互不影响的 为什么这里会出现这样的问题呢? http://www.ziyoubaba.com/archives/585 这个人的说法让我有些迷糊了 请帮我解答一下(新手 ,在学习中~ 勿怪)
2018-04-16 00:36:19 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676 👏 感谢 我明天改一下 晚安😊
2018-04-16 00:31:04 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676 这么晚了 还帮我解答问题 再来感谢一下 👍👍
2018-04-16 00:27:01 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676 奥 原来如此 感谢感谢 然后 我还想问一下 要是不使用全局变量 怎么在不同的请求直接传递数据? 存到数据库或者保存成 json 文件?
2018-04-16 00:01:03 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676

@app.route('/')
def index():
k = request.remote_addr
m = request.user_agent
session['user'] = k+m.browser+m.platform+m.string+m.version
return render_template('Default.html')

是不是这里写错了 我没有写登录的页面 但是想获取浏览器的信息 作为 sessions 或者 cookie 的信息
2018-04-15 23:59:13 +08:00
回复了 charlescwj 创建的主题 Python Flask 的一个问题,求教大佬
@John60676 这是我 views 代码的一部分 觉得问题应该就在这里
from app import app
from flask import render_template,request,flash,session
from .models import CostForm,dowmlist
import numpy as np
from flask import make_response


# 全局基础数据
Salary_Increase = 0.02 #工资涨幅,
Rate_Insurance = 0.48 #五险一金占年薪的百分比
Rate_Welfare = 0.06 #其他福利占年薪的百分比
Rate_CommonRepair = 0.55
Rate_BigRepair = 0.45
Rate_LineRepair = 0.5
Rate_StructureRepair = 0.2
Rate_DeviceRepair = 0.3

TrainPower = 1150 #列车额定功率,1150kw
Rate_power = 0.8 #功率利用率

Rate_water = 0.07
Rate_gas = 0.05
Rate_heat = 0.06
Rate_transport = 0.14
Rate_accident = 0.34
Rate_ticket = 0.25
Rate_clean = 0.11
Rate_ManagerSalary = 0.35
Rate_Active = 0.25
Rate_Travel = 0.3
Rate_Education = 0.1
# 存放提交的基础数据
datum={}

# 存放计算后的数据
LineLength = []
Flow = []
TrainCount = []
StaffCount = []
TrainRunKM = []
Salary = []

Total_Salary = []
TrainRepair = []
OtherRepair = []
Train_electric = []
Lighting_electric = []
Total_electric = []
Operation = []
Management = []
TotalCost = []

@app.route('/')
def index():
k = request.remote_addr
m = request.user_agent
session['user'] = k+m.browser+m.platform+m.string+m.version
return render_template('Default.html')


@app.route('/base')
def base():
return render_template('base.html')

@app.route('/Input', methods=('GET', 'POST'))
def register():
form = CostForm()
if form.validate_on_submit():

flash("sucess")
# 其他数据
datum['Cal_year']=form.text_year.data
datum['Investment']=form.text_investment.data
datum['speed']=form.text_speed.data
datum['BaseSalary']=form.text_salary.data
datum['Price_TrainRepair']=form.text_trainRepair.data
datum['Price_OtherRepair']=form.text_repair.data
datum['Price_electric']=form.text_e_cost.data
datum['Price_Operation']=form.text_operation.data
datum['Rate_management']=form.text_management.data/100
for i in range(form.text_year.data):
if i<3:
LineLength.append(form.text_length1.data)
Flow.append((0.8 + i / 10)*form.text_flow1.data)
TrainCount.append((0.8 + i / 10) * form.text_train1.data)
StaffCount.append((0.8 + i / 10) * form.text_person1.data)
Lighting_electric.append(datum['Price_electric'] * (0.8 + i / 10) * form.text_e1.data)
elif 3<=i<10:
LineLength.append(form.text_length1.data)
Flow.append(form.text_flow1.data+(i - 2) * (form.text_flow2.data - form.text_flow1.data)/ 7)
TrainCount.append(form.text_train1.data+(i - 2) * (form.text_train2.data - form.text_train1.data)/ 7)
StaffCount.append(form.text_person1.data+(i - 2) * (form.text_person2.data - form.text_person1.data)/ 7)
Lighting_electric.append(datum['Price_electric'] *( form.text_e1.data + (i - 2) * (form.text_e2.data - form.text_e1.data) / 7))
elif 10<=i<25:
LineLength.append(form.text_length2.data)
Flow.append(form.text_flow2.data + (i - 9) * (form.text_flow3.data - form.text_flow2.data) /15)
TrainCount.append(form.text_train2.data + (i - 9) * (form.text_train3.data - form.text_train2.data)/15)
StaffCount.append(form.text_person2.data + (i - 9) * (form.text_person3.data - form.text_person2.data)/15)
Lighting_electric.append(datum['Price_electric']*(form.text_e2.data + (i - 9) * (form.text_e3.data - form.text_e2.data)/15))
else:
LineLength.append(form.text_length3.data)
Flow.append(form.text_flow3.data)
TrainCount.append(form.text_train3.data)
StaffCount.append(form.text_person3.data)
Lighting_electric.append(datum['Price_electric'] * form.text_e3.data)

TrainRunKM.append(LineLength[i] * TrainCount[i] * 2 * 365 * 1.1 / 10000)
Salary.append(LineLength[i] * StaffCount[i] * datum['BaseSalary'] * (1 + Salary_Increase)**i)
Total_Salary.append(round(Salary[i] * (1 + Rate_Insurance + Rate_Welfare),1))
TrainRepair.append(round(datum['Price_TrainRepair'] * TrainRunKM[i],1))
OtherRepair.append(round(datum['Price_OtherRepair'] * TrainRunKM[i],1))
# Train_electric[i] = datum['Price_electric'] * TrainPower * Rate_power * TrainRunKM[i] / datum['speed']
Train_electric.append(round(datum['Price_electric']* 5 * TrainRunKM[i],1))
Total_electric.append(round(Train_electric[i] + Lighting_electric[i],1))
Operation.append(round(datum['Price_Operation'] * TrainRunKM[i],1))

TotalCost.append(round((Total_Salary[i] + TrainRepair[i] + OtherRepair[i] + Total_electric[i] + Operation[
i]) / (1-datum['Rate_management']),1))
Management.append(round(datum['Rate_management'] * TotalCost[i],1))
# 添加跳转页面或者弹窗
return render_template('Input.html', form=form)


@app.route('/simple')
def simple():
year=datum['Cal_year']
all_total_salary = round(sum(Total_Salary),1)
all_trainrepair = round(sum(TrainRepair),1)
all_otherrepair = round(sum(OtherRepair),1)
all_total_electric = round(sum(Total_electric),1)
all_operation = round(sum(Operation),1)
all_management = round(sum(Management),1)
all_totalcost = round(sum(TotalCost),1)
return render_template('simple.html', all_total_salary=all_total_salary,all_trainrepair=all_trainrepair,all_otherrepair=all_otherrepair,all_total_electric=all_total_electric,all_operation=all_operation,all_management=all_management,all_totalcost=all_totalcost,year=year,Total_Salary=Total_Salary,TrainRepair=TrainRepair,OtherRepair=OtherRepair,Total_electric=Total_electric,Operation=Operation,TotalCost=TotalCost,Management=Management)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2620 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 11:27 · PVG 19:27 · LAX 03:27 · JFK 06:27
Developed with CodeLauncher
♥ Do have faith in what you're doing.