我在使用 brew 时遇到了 openssl 和 python@2 问题,这里已经解释了(未解决)。重新安装 Python 和 openssl 的文档化解决方法不起作用,所以我决定卸载并重新安装 Python。
问题是,当您尝试使用 brew 安装 Python 2 时,您会收到以下消息:
brew install python@2
Error: No available formula with the name "python@2"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
python@2 was deleted from homebrew/core in commit 028f11f9e:
python@2: delete (https://github.com/Homebrew/homebrew-core/issues/49796)
EOL 1 January 2020.
We gave it 1 month more …
Run Code Online (Sandbox Code Playgroud) 尝试运行 AWS CLI 时,我收到此错误:
aws
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported …
Run Code Online (Sandbox Code Playgroud) 检索 pod 中运行的所有容器的解决方案是运行kubectl get pods POD_NAME_HERE -o jsonpath={.spec.containers[*].name}
,但是此命令行不提供 init 容器。
有没有办法干净地检索 Pod 中运行的所有容器,包括 init 容器?
[编辑] 正如 svenwltr 所指出的,在 Kubernete 1.6.0 或更高版本上,可以使用 检索 init 容器,并且kubectl get pods POD_NAME_HERE -o jsonpath={.spec.initContainers[*].name}
可以使用 检索所有容器kubectl get pod POD_NAME_HERE -o jsonpath="{.spec['containers','initContainers'][*].name}"
。.spec.initContainers
但是,对于尚未实现的较低版本的 Kubernetes 来说,这不是有效的解决方法。
我有问题在d3中创建对数刻度.如果设置为线性,则刻度可以正常工作.
这有效:
var myLinScale = d3.scale.linear()
.domain([0, 100])
.range([50, 1150]);
console.log(myLinScale(71)); //output = 831
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用:
var myLogScale = d3.scale.log()
.domain([0, 100])
.range([50, 1150]);
console.log(myLogScale(71)); //output = NaN
Run Code Online (Sandbox Code Playgroud)
对数刻度有什么问题?
我有一个gif
我想调整大小,pillow
以便它的大小减少.目前的大小gif
是2MB.
我在尝试着
调整大小,使其高度/宽度更小
降低其质量.
使用JPEG,以下代码通常就足以使大图像的大小显着减小.
from PIL import Image
im = Image.open("my_picture.jpg")
im = im.resize((im.size[0] // 2, im.size[1] // 2), Image.ANTIALIAS) # decreases width and height of the image
im.save("out.jpg", optimize=True, quality=85) # decreases its quality
Run Code Online (Sandbox Code Playgroud)
但是,使用GIF,它似乎不起作用.以下代码甚至out.gif
比最初的gif更大:
im = Image.open("my_gif.gif")
im.seek(im.tell() + 1) # loads all frames
im.save("out.gif", save_all=True, optimize=True, quality=10) # should decrease its quality
print(os.stat("my_gif.gif").st_size) # 2096558 bytes / roughly 2MB
print(os.stat("out.gif").st_size) # 7536404 bytes / roughly 7.5MB
Run Code Online (Sandbox Code Playgroud)
如果我添加以下行,则仅保存GIF的第一帧,而不是其全部帧.
im …
Run Code Online (Sandbox Code Playgroud) 所以说我有下表:
In [2]: df = pd.DataFrame({'a': [1,2,3], 'b':[2,4,6], 'c':[1,1,1]})
In [3]: df
Out[3]:
a b c
0 1 2 1
1 2 4 1
2 3 6 1
Run Code Online (Sandbox Code Playgroud)
我可以这样总结a和b:
In [4]: sum(df['a']) + sum(df['b'])
Out[4]: 18
Run Code Online (Sandbox Code Playgroud)
但是,对于较大的数据帧,这不是很方便,您需要将多个列相加在一起.
是否有一种更简洁的方法来对列进行求和(类似于下面的内容)?如果我想在不指定列的情况下对整个DataFrame求和,该怎么办?
In [4]: sum(df[['a', 'b']]) #that will not work!
Out[4]: 18
In [4]: sum(df) #that will not work!
Out[4]: 21
Run Code Online (Sandbox Code Playgroud) 我有以下一段代码,当用户单击“提交”按钮时,它将显示一个地图。
目前,函数initialize()没有任何参数,并且地图以固定的纬度和经度为中心。我希望能够将纬度和经度作为参数,以便地图以此为中心。
我已经有了经度和纬度,因此获取这些参数不是问题;我的问题是我不知道如何将它们传递给函数。
完整代码:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<div id="map">
<button type="button" onclick="loadScript()">submit</button>
</div>
<script>
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
myOptions);
}
function loadScript() {
var myKey = "myAPIKey";
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://maps.googleapis.com/maps/api/js?key=" + myKey + "&sensor=false&callback=initialize";
document.body.appendChild(script);
}
</script>
</body> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我自己的计算机上运行本地 mysql 服务器。我丢失了最初设置的密码。当我尝试连接到 mysql 时,出现以下错误:
ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)
因此,我尝试了这些步骤来重置我的 MySQL 密码,但该行
mysql -u 根 mysql
返回相同的错误消息:
ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)
运行命令时
mysqladmin -u root -p status 我收到以下消息:错误:'无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)'
检查 mysqld 是否正在运行以及套接字:'/var/run/mysqld/mysqld.sock' 是否存在!
我一直在检查,提到的文件(/var/run/mysqld/mysqld.sock)实际上并不存在。我不确定是什么原因造成的。
我在网上尝试了几个解决方案,包括这个、这个、这个和这个,但是这些解决方案都不适合我。我想补充一点,我的机器上安装了 mysql-server。
任何帮助表示赞赏。如果以上陈述有任何混淆,请接受我的歉意。我试图尽可能多地解释正在发生的事情,但我是一个初学者,我对那里发生的事情一无所知。
我正在 Ruby 中解析 YAML 文件,某些输入导致 Psych 语法错误:
require 'yaml'
example = "my_key: [string] string"
YAML.load(example)
Run Code Online (Sandbox Code Playgroud)
导致:
Psych::SyntaxError: (<unknown>): did not find expected key
while parsing a block mapping at line 1 column 1
from [...]/psych.rb:456:in `parse'
Run Code Online (Sandbox Code Playgroud)
我从我无法控制的外部 API 收到此 YAML。我可以看到编辑输入以强制解析为字符串,使用my_key: '[string] string'
,如“我需要在 YAML 中为字符串添加引号吗?”中所述。,可以解决问题,但我无法控制如何接收输入。
有没有办法强制将输入解析为某些键(例如 )的字符串 my_key
?是否有解决方法可以成功解析此 YAML?
在 sqlite3 数据库中,我将日期和时间存储为 unix 时间戳。UNIX时间戳的例子中,我们可以找到我们的数据库:1457600307000, 1457600109000, 1457599991000
。
执行以下查询时:
SELECT datetime(my_date, 'unixepoch') as last_update
FROM my_table;
Run Code Online (Sandbox Code Playgroud)
结果不是我们所期望的。我们从执行该查询中获得的日期是:-1413-03-01 13:07:12
当我们真正期望从March / April 2016
.
无论如何我可以sqlite3
正确读取时间戳吗?
我正在尝试使用select
AWS CLI中的AWS SimpleDB命令.
所需的电话如下:
select
--select-expression <value>
与select-expression
被描述如下:--select-expression (string) The expression used to query the domain.
select应该与SQL
select语句类似,但是我不断收到语法错误,例如:
aws sdb select --select-expression "select * from my-domain"
An error occurred (InvalidQueryExpression) when calling the Select operation: The specified query expression syntax is not valid.
我也找不到任何关于正确使用语法的文档或示例.
python ×4
homebrew ×2
javascript ×2
macos ×2
callback ×1
d3.js ×1
dataframe ×1
gif ×1
google-maps ×1
kubernetes ×1
logarithm ×1
math ×1
mysql ×1
pandas ×1
pillow ×1
psychparser ×1
python-2.7 ×1
python-2.x ×1
ruby ×1
sockets ×1
sqlite ×1
yaml ×1