我正在开发一个C#项目,我必须在其中构建各种文件和文件夹的路径.这些都在我在Web.config文件中指定的一个根文件夹下.
例如:
我的路径是正确的,但我只想知道不完整路径的最佳实践.我应该在每个文件夹的末尾添加一个"\"("D:\ Builds\5.2 \"+"test.txt"),或者在我添加到路径的每个文件夹/文件的开头添加一个("D" :\构建"+"\ 5.2"+"\ test.txt")?目前,我是两种方式,并且想要选择一种统一的方式.
我想将此输出存储在一个字符串中:
> x=1:5
> cat("hi",x)
hi 1 2 3 4 5
Run Code Online (Sandbox Code Playgroud)
所以我用paste,但我得到了这个不同的结果:
> paste("hi",x)
[1] "hi 1" "hi 2" "hi 3" "hi 4" "hi 5"
Run Code Online (Sandbox Code Playgroud)
知道如何获取字符串:
"hi 1 2 3 4 5"
Run Code Online (Sandbox Code Playgroud)
非常感谢你!
我们的几何老师给了我们一个任务,要求我们创建一个玩具在现实生活中使用几何体的例子,所以我认为制作一个程序来计算需要多少加仑的水来填充某个池才是很酷的.形状,并具有一定的尺寸.
这是迄今为止的计划:
import easygui
easygui.msgbox("This program will help determine how many gallons will be needed to fill up a pool based off of the dimensions given.")
pool=easygui.buttonbox("What is the shape of the pool?",
choices=['square/rectangle','circle'])
if pool=='circle':
height=easygui.enterbox("How deep is the pool?")
radius=easygui.enterbox("What is the distance between the edge of the pool and the center of the pool (radius)?")
easygui.msgbox=("You need "+(3.14*(float(radius)**2) * float(height)) + "gallons of water to fill this pool.")
Run Code Online (Sandbox Code Playgroud)
我不断得到这个错误:easygui.msgbox =("你需要"+(3.14*(浮动(半径)**2)*浮动(高度))+"加仑水来填充这个池.")TypeError:不能连接'str'和'float'对象
我该怎么办?
我很难理解numpy的dstack功能实际上在做什么.文档相当稀疏,只是说:
按顺序深度(沿第三轴)堆叠阵列.
采用一系列数组并沿第三轴堆叠它们以形成单个数组.重建数组除以
dsplit.这是将2D阵列(图像)堆叠到单个3D阵列中进行处理的简单方法.
所以要么我真的很愚蠢,这个含义是显而易见的,或者我似乎对"堆叠","按顺序","深度明智"或"沿轴"这两个术语有一些误解.但是,我的印象是我在上下文中理解这些术语,vstack并且hstack很好.
我们来看这个例子:
In [193]: a
Out[193]:
array([[0, 3],
[1, 4],
[2, 5]])
In [194]: b
Out[194]:
array([[ 6, 9],
[ 7, 10],
[ 8, 11]])
In [195]: dstack([a,b])
Out[195]:
array([[[ 0, 6],
[ 3, 9]],
[[ 1, 7],
[ 4, 10]],
[[ 2, 8],
[ 5, 11]]])
Run Code Online (Sandbox Code Playgroud)
首先,a并b没有第三轴,所以我将如何堆叠起来一起" 的第三轴"以开始?第二,假设a并且b是2D图像的表示,为什么我在结果中最终得到三个 2D数组而不是两个"顺序"的2D数组?
如何将从sql查询返回的差异行中的所有列值连接成一个值?这是一个例子:
查询返回:
FOO ------ RES1 RES2 RES3
现在我希望得到如下结果:
FOOCONCAT ----- RES1RES2RES3
有没有办法在sql中执行此操作?
我有一个充满文本文件的文件夹.我需要将相同的文本块附加到每个文本块(当然还要覆盖原始文件).
我想知道正确的Bash shell语法是什么.我会用猫吗?
我做了一些批处理脚本,但我不是Bash专家.任何建议赞赏.
我正在尝试设置一个脚本来连接字符串中的一些变量(如果它们存在),以便将适当的元数据标记放入呈现的HTML文档中.
我的连接代码是:
data = "<html>\n<head>\n" + "</head>\n<body>\n\n" + paras.join("\n\n") + "\n\n</body>\n</html>";
Run Code Online (Sandbox Code Playgroud)
我正在尝试将if以下语句添加到其中(在第一个和第二个项目之间):
if (typeof metadata_title !== "undefined") {
"<title>" + metadata_title + "</title>\n"
}
if (typeof metadata_author !== "undefined") {
"<meta name=\"author\" content=\"" + metadata_author + "\"></meta>\n"
}
if (typeof metadata_date !== "undefined") {
"<meta name=\"date\" content=\"" + metadata_date + "\"></meta>\n"
}
Run Code Online (Sandbox Code Playgroud)
但我无法将这些语句中的任何一个直接添加到连接代码中(它会引发错误:) Unexpected token (.
我最好如何将这些语句添加到我的串联字符串中?
我有一个处理DataFrame的函数,主要是将数据处理成桶,在特定列中使用创建二进制矩阵的特征pd.get_dummies(df[col]).
为了避免一次使用此函数处理我的所有数据(内存不足并导致iPython崩溃),我使用以下方法将大型DataFrame分解为块:
chunks = (len(df) / 10000) + 1
df_list = np.array_split(df, chunks)
Run Code Online (Sandbox Code Playgroud)
pd.get_dummies(df)会自动创建一个基于内容的新栏目df[col]和这些都有可能为每个不同df在df_list.
处理完毕后,我使用以下方法将DataFrame连接在一起:
for i, df_chunk in enumerate(df_list):
print "chunk", i
[x, y] = preprocess_data(df_chunk)
super_x = pd.concat([super_x, x], axis=0)
super_y = pd.concat([super_y, y], axis=0)
print datetime.datetime.utcnow()
Run Code Online (Sandbox Code Playgroud)
第一个块的处理时间是完全可以接受的,然而,它每块增长!这与它没有关系,preprocess_data(df_chunk)因为没有理由增加它.由于呼叫的结果,是否会增加时间pd.concat()?
请参阅下面的日志:
chunks 6
chunk 0
2016-04-08 00:22:17.728849
chunk 1
2016-04-08 00:22:42.387693
chunk 2
2016-04-08 00:23:43.124381
chunk 3
2016-04-08 00:25:30.249369
chunk 4
2016-04-08 00:28:11.922305
chunk 5
2016-04-08 00:32:00.357365 …Run Code Online (Sandbox Code Playgroud) python performance concatenation processing-efficiency pandas
我是一个新__CODE__学习者.我有一个数组__CODE__从标准输入中获取输入.我必须连接两次.说,我在数组中有以下元素:
Namibia
Nauru
Nepal
Netherlands
NewZealand
Nicaragua
Niger
Nigeria
NorthKorea
Norway
Run Code Online (Sandbox Code Playgroud)
现在,输出应该是:
Namibia Nauru Nepal Netherlands NewZealand Nicaragua Niger Nigeria NorthKorea Norway Namibia Nauru Nepal Netherlands NewZealand Nicaragua Niger Nigeria NorthKorea Norway
Run Code Online (Sandbox Code Playgroud)
我的代码是:
countries=()
while read -r country; do
countries+=( "$country" )
done
countries=countries+countries+countries # this is the wrong way, i want to know the right way to do it
echo "${countries[@]}"
Run Code Online (Sandbox Code Playgroud)
请注意,我可以像下面的代码一样打印三次,但这不是我的座右铭.我必须在数组中连接它们.
countries=()
while read -r country; do
countries+=( "$country" )
done
echo "${countries[@]} ${countries[@]} …Run Code Online (Sandbox Code Playgroud) 我知道JSX可能会非常误导,因为它看起来像字符串,它不是,因此问题中的"字符串"术语,即使我们并没有真正操纵字符串.
这是一个代码示例(显然错误):
let line = <Line key={line.client_id} line={line}/>;
if(line.created_at) {
return <div className="date-line"><strong>{line.created_at}</strong></div> + line;
} else {
return chat_line;
}
Run Code Online (Sandbox Code Playgroud)
我有一条线,我想在某些条件下"连接"前面的一些div.什么是正确的语法?我试过括号,括号,加号......它们似乎都不起作用......
谢谢