从源代码构建Python 3.7会遇到以下错误:
Failed to build these modules:
_hashlib _ssl
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
Run Code Online (Sandbox Code Playgroud)
我从其他stackoverflow问题尝试了很多变通方法,但它不起作用.我从源代码构建最新的OpenSSL和LibreSSL.OpenSSL路径是:"/ usr/local/ssl",版本为OpenSSL 1.0.2p.
./configure --with-openssl=/usr/local/ssl/
(./configure CPPFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib")
make
make altinstall
Run Code Online (Sandbox Code Playgroud)
我的系统:Ubuntu 12.04.5 LTS
有任何想法吗?
我用matplotlib/pyplot绘制一个简单的线图.在同一个图中,最多有20行.Matplotlib自动选择线条颜色.我需要用较粗的红色画出第一行.
所以我试过:
if (i==0): # first line
plt.plot(x, y, 'r', lw=2.5)
else: # other lines
plt.plot(x, y)
Run Code Online (Sandbox Code Playgroud)
到目前为止非常简单.第一行是正确的.但其他一条线也是红色的.怎么能避免这个?
我在使用matplotlib/pyplot/basemap时遇到了麻烦.我在地图上绘制轮廓线(气压).我使用clabel来显示轮廓线的值.但问题是:值和轮廓线之间的填充太多.我找到了参数"inline_spacing",我将其设置为零.但仍有很多自由空间.有任何想法吗?
Python代码:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import pygrib
filename = "file.grib2"
grbs = pygrib.open('/data/' + filename)
grb = grbs[2]
data = grb.values
datac = data*0.01
lats, lons = grb.latlons()
fig = plt.figure()
m = Basemap(projection='stere',lon_0=5,lat_0=90.0,\
llcrnrlon=-25.0,urcrnrlon=60.0,llcrnrlat=30.0,urcrnrlat=60.0,resolution='l')
x, y = m(lons, lats)
levs = range(940,1065,5)
S1=plt.contour(x,y,datac,levs,linewidths=0.5,colors='b')
plt.clabel(S1,inline=1,inline_spacing=0,fontsize=8,fmt='%1.0f',colors='b')
m.drawmapboundary(fill_color='w')
m.drawcoastlines(linewidth=0.2)
plt.savefig('test.png', bbox_inches='tight',pad_inches=0.05, dpi=100)
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有一个jQuery验证方法的联系表单.当用户点击"重置"按钮时,孔接触形式应该进入初始状态.
这是按钮看起来像:
<form class="form" method="post" action="" name="contact" id="contact">
<button type="button" id="cancel" class="btn btn-danger btn-lg">Reset</button>
</form>
Run Code Online (Sandbox Code Playgroud)
我的"$(document).ready-function"中的JS-Code是:
$('#cancel').on('click', function () {
$("#contact").validate().resetForm();
$("#contact").removeClass("has-error");
});
Run Code Online (Sandbox Code Playgroud)
问题:错误文本和输入字段将被删除.但不删除红色边框(.has-error)或绿色边框(.has-success).
我为你创建了一个JSFiddle:
一个按钮清除输入文本,另一个是删除错误消息.我需要一个按钮来重置(文本,错误消息)和主要问题,来自has-*类的红色边框.
一个Button被声明为type = submit另一个是type = button:
<button type="button" id="cancel" class="btn btn-danger btn-lg">Reset 1</button>
<button type="reset" id="cancel2" class="btn btn-danger btn-lg">Reset 2</button>
Run Code Online (Sandbox Code Playgroud) 假设,我有一个NumPy整数数组,如:
[34,2,3,22,22,22,22,22,22,18,90,5,-55,-19,22,6,6,6,6,6,6,6,6,23,53,1,5,-42,82]
Run Code Online (Sandbox Code Playgroud)
我想找到数组的开始和结束索引,其中一个值超过x次(比如说5次)重复.所以在上面的例子中,它是值22和6.重复22的起始索引是3,结束索引是8.相同的重复6. Python中是否有一个特殊工具有用?否则,我会遍历索引的数组索引,并将实际值与之前的值进行比较.
问候.
有一个巨大的 pandas 数据框(df),如下所示:
id date a b c
0 0023 201110132120 -30 -45 7
1 0023 201110132130 -30 11 9111
2 0023 201110132140 -24 44 345
3 0023 201110132150 -19 223 11
4 0023 201110132200 -23 -3456 -1250
Run Code Online (Sandbox Code Playgroud)
我需要将此数据帧写入每个字段具有特殊固定宽度的文件中。为此,我使用了 numpy,fe:
np.savetxt('out.txt', df.values, fmt='%+4s %+12s %+5s %+5s %+6s')
Run Code Online (Sandbox Code Playgroud)
那工作还好啊 在这种情况下仅丢失标头。有解决方法吗?
我还用 pandas to_string 函数测试了它:
df.to_string()
Run Code Online (Sandbox Code Playgroud)
但它太慢了。为什么?还有其他选择吗?
我想对 csv 文件进行一些更改。该文件如下所示:
.csv 文件:
04.08.1994 22:47;3.3;29;;61.8;1;4.0;1.4;433;
04.08.1994 23:11;;27;93.0;60.6;2;2.0;6.5;133;
04.08.1994 23:48;3.1;;18.4;93.1;1;1.0;6.8;;
Run Code Online (Sandbox Code Playgroud)
所需的输出:
04.08.1994 22:47;33;29;12345;61.8;20;4.0;1.4;433;
04.08.1994 23:11;12345;27;930;60.6;40;2.0;6.5;133;
04.08.1994 23:48;31;12345;184;93.1;20;1.0;6.8;12345;
Run Code Online (Sandbox Code Playgroud)
应该发生以下情况:
用特殊值替换空字段,例如“12345”。
仅对非空字段执行某些列的算术运算(乘以 10 或 20)。
我的解决方案:
cat file | awk 'BEGIN {FS=OFS=";"} { for(i=1; i<=NF; i++) if($i ~ /^ *$/) $i = 12345 }; \
{ $2!=12345 && ($2=$2*10); $4!=12345 && ($4=$4*10); $6!=12345 && ($6=$6*20); print}'
Run Code Online (Sandbox Code Playgroud)
到目前为止它的工作。想知道我是否必须在每个列操作之前编写这个 if 条件?或者有更简单的方法吗?也许应该在每个字段的循环中执行所有操作?
python ×5
matplotlib ×2
numpy ×2
python-3.x ×2
arrays ×1
awk ×1
dataframe ×1
html ×1
javascript ×1
jquery ×1
openssl ×1
pandas ×1
plot ×1
ssl ×1
validation ×1