我正在使用C#构建的一些代码在Elixir中重建一些东西.
这是非常黑客攻击,但完美的工作(虽然不是在Linux上,因此重建).
基本上它做的是检查一些RSS提要并查看是否有任何新内容.这是代码:
Map historic (URL as key, post title as value).
List<string> blogfeeds
while true
for each blog in blogfeeds
List<RssPost> posts = getposts(blog)
for each post in posts
if post.url is not in historic
dothing(post)
historic.add(post)
Run Code Online (Sandbox Code Playgroud)
我想知道如何在Elixir中有效地进行Enumeration.而且,似乎我在"历史性"中添加东西的过程就是反功能编程.
显然,第一步是声明我的URL列表,但除此之外,枚举的想法正在弄乱我的脑袋.有人可以帮帮我吗?谢谢.
我尝试使用以下方法从 Python 3.3 访问 MySQL:
import mysql.connector
config = {
'user': '###',
'password': '******',
'host': '##.##.#.##',
'database': '########',
'port': '####',
'raise_on_warnings': True,
}
cnx = mysql.connector.connect(**config)
cnx.close()
Run Code Online (Sandbox Code Playgroud)
但是当我运行上面的代码时,我收到了这个错误:
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user '###'@'##.##.#.###' (using password: YES);
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误,我该如何解决?
我试图复制一个自定义的类的实例在Python 3.3,类似于如何dict.copy()和list.copy()工作。我该怎么办?
这是我的自定义类的示例:
class CustomClass(object): # Custom class example
def __init__(self, thing):
self.thing = thing
Run Code Online (Sandbox Code Playgroud) 我想将图像的像素打印为矩阵。
这是我正在使用的代码:
from PIL import Image
im = Image.open("8Black.png")
pixels = list(im.getdata())
print(pixels)
Run Code Online (Sandbox Code Playgroud)
我使用photoshop创建了图像“8Black.png”并将其涂成黑色。我使用的 python 版本是 3.5.0。但是,当我运行上面的代码时,我得到:
[0,0,0,0,0,0,0,0,0,0,0,0,...,0]
Run Code Online (Sandbox Code Playgroud)
我想得到这个:
[[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[...],[...]]
Run Code Online (Sandbox Code Playgroud)
我试着改变这个:
pixels = list(im.getdata())
Run Code Online (Sandbox Code Playgroud)
对此:
pixels = np.matrix(im.getdata())
Run Code Online (Sandbox Code Playgroud)
但还是没有得到我想要的结果。
如何将像素数据作为矩阵获取?我错过了什么?
我有一个像这样的脚本:
<span>Famous Quote:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
var Quotation=new Array() // do not change this!
Quotation[0] = "Time is of the essence! Comb your hair.";
Quotation[1] = "Sanity is a golden apple with no shoelaces.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "Honesty blurts where deception sneezes.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the …Run Code Online (Sandbox Code Playgroud) 在BF中,我知道您可以使用+和-运算符进行加法和减法,并且您可以将两个预定义的数字相乘,如下所示:
Multiply 4 and 4
++++[>++++<-]
Run Code Online (Sandbox Code Playgroud)
但是,如何将两个变量相乘,或者使用其他数学运算符,例如模数或除法?
在Perl中,如果我运行此代码:
print $a
Run Code Online (Sandbox Code Playgroud)
它什么都不打印,告诉我$a(或任何其他不特殊的变量)的价值undef.
但是,如果我运行此代码:
print $%
Run Code Online (Sandbox Code Playgroud)
我反而得到这个:
0
Run Code Online (Sandbox Code Playgroud)
从Perldoc中的perlvar我看到这个描述$%:
当前所选输出通道的当前页码.
我不明白.什么输出通道?一个像STDOUT,还是其他什么?
python ×3
brainfuck ×1
elixir ×1
enumeration ×1
file ×1
image ×1
javascript ×1
math ×1
mysql ×1
perl ×1
php ×1
pixels ×1
python-3.x ×1