我用generate_password_hash的werkzeug.security到的散列和盐我的密码.我最近看到这篇关于SHA-1碰撞的文章.werkzeug.security使用SHA-1,因为它不再安全,我想要一个替代品.如何在不依赖SHA-1的情况下散列我的密码?
from werkzeug.security import generate_password_hash
generate_password_hash(secret)
Run Code Online (Sandbox Code Playgroud) 我想要一个CSS侧边栏和一个粘性页脚.当侧边栏滑出时,页面的其余部分应缩小以适应较小的空间.
我的问题是,当我打开菜单时,粘性页脚将滑向侧边病房.但它也需要缩小,但事实并非如此.它应该像其他内容一样水平放在页面上,但事实并非如此.这导致了我不想要的水平滚动条.
我该如何缩小页脚?
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
footer {
bottom: 0;
margin-left: inherit;
height: 100px;
left: 0;
width: 100%;
position: absolute;
background-color: lightgrey;
}
ul {
margin-left: 0;
padding-left: 0;
}
.footer-img {
margin-top: 15px;
margin-bottom: 15px;
display: inline-block;
}
.page-wrap {
box-sizing: border-box;
min-height: 100%;
position: relative;
transition-duration: 0.4s;
}
.page-content {
box-sizing: border-box;
min-height: 100%;
padding: 0 0 100px 0;
transition-duration: 0.4s;
}
.sidebar {
position: fixed;
top: 0;
left: -180px;
right: …Run Code Online (Sandbox Code Playgroud)我创建了一个布尔字段.布尔值显示但标签不显示.
class product_pricelist_inherit(models.Model):
_inherit = 'product.pricelist'
myfield= fields.Boolean(string="Is this Pricelist Eligible for Me?")
Run Code Online (Sandbox Code Playgroud)
XML:
<odoo>
<record id="product_product_pricelist_view" model="ir.ui.view">
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="myfield"/>
</field>
</field>
</record>
</odoo>
Run Code Online (Sandbox Code Playgroud) 我正在用来flask-wtforms创建一个文本区域。
body = TextAreaField('body')
Run Code Online (Sandbox Code Playgroud)
我想更改文本区域的值,您可以像这样在 html 中执行此操作。
<textarea>other value then default</textarea>
Run Code Online (Sandbox Code Playgroud)
如何将其与 Flask-wtforms 集成?
我的模板如下所示:
{{ form.body(rows="20") }} <!--texarea -->
Run Code Online (Sandbox Code Playgroud)
通过一个简单的输入字段,我可以做这样的事情:
{{ form.body(value="other value then default") }} <!-- input field -->
Run Code Online (Sandbox Code Playgroud)
我需要在模板本身中设置默认值。因为它将包含该页面所涉及的文章的信息。
我在 python 中加载了一个 .csv 文件numpy.genfromtxt。现在它numpy.ndarray在该数组中返回一个一维numpy.void对象,这些对象实际上只是整数数组。但是我想将这些从类型转换numpy.void为numpy.array. 澄清:
>>> print(train_data.shape)
(42000,)
>>> print(type(train_data[0]))
<class 'numpy.void'>
>>> print(train_data[0])
(9, 0, 0)
Run Code Online (Sandbox Code Playgroud)
所以这里有类型的数组 (9, 0, 0)numpy.void应该是 a numpy.array。
如何将所有值转换train_data为 numpy 数组?
效率也有些重要,因为我正在处理大量数据。
还有一些代码
>>> with open('filename.csv, 'rt') as raw_training_data:
>>> train_data = numpy.genfromtxt(raw_training_data, delimiter=',', names=True, dtype=numpy.integer)
>>> print(train_data.dtype)
[('label', '<i4'), ('pixel0', '<i4'), ('pixel1', '<i4')]
>>> print(type(train_data))
<class 'numpy.ndarray'>
Run Code Online (Sandbox Code Playgroud) 我有一个arduino连接到我的电脑(COM9),我有3个python脚本.第一个通过串行发送"1".第二个在串行上发送"0".第三个发送一个你给它的词.
ser.write("1")
Run Code Online (Sandbox Code Playgroud)
然后在我的arduino上我有一些代码.如果启动了python脚本1,它将打开一个led.如果启动2秒脚本,它将关闭一个led.如果启动了python脚本3,它会将该字打印到lcd.
所有硬件配置正确.问题是,当我运行脚本1时,不仅led会打开,而且lcd上也会有1.其他2个脚本按预期工作.
这是我的arduino代码的一部分.
if (Serial.available())
{
wordoftheday = Serial.readString();
if (wordoftheday == "1"){email = true;}
if (wordoftheday == "0"){email = false;}
else {
lcd.clear();
lcd.print(wordoftheday);
}
}
if (email == true){digitalWrite(9, HIGH);}
if (email == false){digitalWrite(9, LOW);}
Run Code Online (Sandbox Code Playgroud) 我想从一个字符串(第三个)得到一些整数.不使用正则表达式优先.
我看到了很多东西.
我的字符串:
xp = '93% (9774/10500)'
Run Code Online (Sandbox Code Playgroud)
所以我希望代码返回一个包含字符串整数的列表.所以期望的输出将是:[93, 9774, 10500]
像这样的东西不起作用:
>>> new = [int(s) for s in xp.split() if s.isdigit()]
>>> print new
[]
>>> int(filter(str.isdigit, xp))
93977410500
Run Code Online (Sandbox Code Playgroud)