是否有命令行命令可以判断mod deflate是否在Apache上运行?
我很困惑 round 和 bround 在 Spark sql 中是如何工作的。
scala> spark.sql("select round(1.5, 0), bround(1.5, 0)").show()
+-------------+--------------+
|round(1.5, 0)|bround(1.5, 0)|
+-------------+--------------+
| 2| 2|
+-------------+--------------+
scala> spark.sql("select round(2.5, 0), bround(2.5, 0)").show()
+-------------+--------------+
|round(2.5, 0)|bround(2.5, 0)|
+-------------+--------------+
| 3| 2|
+-------------+--------------+
scala> spark.sql("select round(3.5, 0), bround(3.5, 0)").show()
+-------------+--------------+
|round(3.5, 0)|bround(3.5, 0)|
+-------------+--------------+
| 4| 4|
+-------------+--------------+
Run Code Online (Sandbox Code Playgroud) 我有一个包含很多行的 file.txt 文件。我希望随机选择任何一行并通过电子邮件发送。这个循环了三次。
import smtplib,datetime,random
def mail(em):
#print "yo"
fromAddress = "atadmorecouth@gmail.com"
toAddress = "atadmorecouth@gmail.com"
subject = "WOW " + str(datetime.datetime.now())
#print subject
msg = em
server=smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
password = "mypassword"
server.login(fromAddress, password)
server.sendmail(fromAddress, toAddress, msg)
#print server.sendmail(fromAddress, toAddress, msg)
for i in range(0,3):
em=str(random.choice(list(open('file.txt'))))
mail(em)
Run Code Online (Sandbox Code Playgroud)
这段代码不起作用。登录一切都很好。我注意到的唯一问题是 server.sendmail(fromAddress, toAddress, msg) 返回一个空的 {} 对此可能有什么解决办法?首先问题出在哪里?我已经在终端中运行了 mail() 函数,看起来工作正常。所有文件都托管在这里
在我的kafka集群中有超过2k个主题,每个主题有5个分区。我只想列出没有领导者的分区。
我可以使用以下语法检查每个主题:
kafka-topics.sh --describe --topic <topic_name> --zookeeper <zookeeper_ip>:port
Run Code Online (Sandbox Code Playgroud)
但问题是有2k+主题,无法手动完成。我还可以编写一个脚本来循环每个主题并获取没有领导者的分区。但我对获取信息的有效方式感兴趣。
我有一个目录,其中包含许多具有以下格式的文件:
1 or 2 numbers_S followed by 1 or 2 numbers_L001_R1 or R2_001.fastq
Examples: 1_S1_L001_R1_001.fastq or 14_S14_L001_R2_001.fastq
Run Code Online (Sandbox Code Playgroud)
我希望文件名是这样的: 1_R1.fastq 14_R2.fastq
我已经想出了regexp
反映文件名的内容,并且可以成功地进行搜索和替换TextWrangler
.以下是我提出的正则表达式:
Search: (\d+)\wS\d+\wL001\w(R\d)\w001(\.fastq)
Replace: \1_\2\3 (or $1_$2$3 depending on the program)
Run Code Online (Sandbox Code Playgroud)
但是,我想知道如何使用简单的Python脚本批量重命名文件.我很感激任何建议.
谢谢!
我目前正在研究项目,我的项目工作正常并且可以正常工作。但是我想在跑步时取消警告sbt compile
。当我运行时,sbt compile
我不希望我的终端显示警告。
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:14: imported `QueryString' is permanently hidden by definition of class QueryString in package misc
[warn] import misc.QueryString
[warn] ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:26: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn] val resultSet = query().map(
[warn] ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:58: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn] val resultSet = query().map(
[warn] …
Run Code Online (Sandbox Code Playgroud) >>> a = "2016-03-22 12:33:45.7565"
>>> datetime.datetime.strptime(a, "%Y-%m-%d %H:%M:%f")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: .7565
>>> datetime.datetime.strptime(a, "%Y-%m-%d %H:%M:%S")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: .7565
Run Code Online (Sandbox Code Playgroud)
我已经使用%S
和%f
,但我怎么能应付秒钟,如果是类型float
?
任何帮助,将不胜感激
int value =5;
void testPointer( int* pa, int* pb) {
*pa = *pb +5;
*pb = value;
value += 10;
}
Run Code Online (Sandbox Code Playgroud)
我如何区分两者?我不明白
我正在学习 C 中的命令行参数。有一个部分我应该用 argv[i] 的位置定义 char 变量。我尝试使用argv[2]
,但它显示一些警告( warning: initialization of 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion] )
每当我这样做时argv[2][0]
,它确实有效。
为什么最后有一个0。对我来说这似乎是一个二维数组。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a, b, sum = 0 ;
char operate = argv[2][0] ; //I tried running it by using argv[2], but it showing a conversion error
// warning: initialization of 'char' from 'char *' makes integer from pointer without a cast …
Run Code Online (Sandbox Code Playgroud) 我正在学习 C 语言中的函数,但遇到了一个问题。
这是代码:
#include <stdio.h>
#include <stdlib.h>
void equivalenza(int, int , int);
int main()
{
int ore, minuti, secondi;
printf("Inserisci ore, minuti e secondi (hh-mm-ss): ");
scanf("%d-%d-%d", ore, minuti, secondi);
equivalenza(ore, minuti, secondi);
return 0;
}
void equivalenza(int ore, int minuti, int secondi)
{
secondi = secondi + ore*3600;
secondi = secondi + minuti*60;
printf("\nSecondi = %d", secondi);
}
Run Code Online (Sandbox Code Playgroud)
输出只是没有启动我认为的功能。
Inserisci ore, minuti e secondi (hh-mm-ss): 34-32-52
Process returned -1073741819 (0xC0000005) execution time : 13.287 s
Run Code Online (Sandbox Code Playgroud) c ×3
python ×3
scala ×2
apache ×1
apache-kafka ×1
apache-spark ×1
arrays ×1
batch-rename ×1
datetime ×1
dereference ×1
email ×1
mod-deflate ×1
pointers ×1
python-2.7 ×1
regex ×1
rename ×1
sbt ×1
sendmail ×1
smtplib ×1