我无法理解这段代码的输出?
int main()
{
FILE* f, *f1;
f = fopen("mytext", "w");
if ((f1 = fopen("mytext", "w")) == 0)
printf("unable\n");
fprintf(f, "hello\n");
fprintf(f1, "hi\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
OUTPUT是mytext文件中的hello.为什么不写?"无法"不打印到标准输出.
在下面的第一个程序中没有错误.但是对于第二个程序存在错误.为什么会这样?
第一个项目:
#include<stdio.h>
void main()
{
int k=8;
int m=7;
k<m?k=k+1:m+1;
printf("%d",k);
}
Run Code Online (Sandbox Code Playgroud)
第二个方案:
#include<stdio.h>
void main()
{
int k=8;
int m=7;
k<m?k=k+1:m=m+1;
printf("%d",k);
}
Run Code Online (Sandbox Code Playgroud) 我对这些代码有问题.
if tdinst[0].string in features:
nameval=tdinst[0].string
value=tdinst[1].string
print type(value)
if type(value) is not None:
print"it should not come here"
value=value.replace("\n","")
value=value.replace("\t","")
Run Code Online (Sandbox Code Playgroud)
我得到'NoneType'对象没有属性'replace'.为什么它会进入第二个条件?
下面是一个小的 PowerShell 脚本。
function test() {
$paramstring = "name=vindhya
id=182122"
$hash_params = convertfrom-stringdata -stringdata $paramstring
Write-Host $hash_params
callee $hash_params
}
function callee() {
param($hash_params)
#$hash_params
}
test
Run Code Online (Sandbox Code Playgroud)
输出是System.Collections.Hashtable。
但如果将Write-Host替换为Write-Output那么,
function test() {
$paramstring="name=vindhya
id=182122"
$hash_params = convertfrom-stringdata -stringdata $paramstring
Write-Output $hash_params
callee $hash_params
}
function callee() {
param($hash_params)
#$hash_params
}
test
Run Code Online (Sandbox Code Playgroud)
输出是
Name Value
---- -----
name vindhya
id 182122
Run Code Online (Sandbox Code Playgroud)
为什么 Write-Host 和 Write-Output 的行为不同?
我想得到一个特定键的所有值(多个).但我只获得一个值?我不知道如何打印所有值.如果有人更正代码,那么很有帮助..没有得到谷歌搜索的任何帮助. .
import java.util.*;
public class hashing
{
public static void main(String args[])
{
String[] ary=new String[4];
String key;
char[] chrary;
ary[0]=new String("abcdef");
ary[1]=new String("defabc");
ary[2]=new String("ghijkl");
ary[3]=new String("jklghi");
Hashtable<String, String> hasht = new Hashtable<String, String>();
for(int i=0;i<4;i++){
chrary=ary[i].toCharArray();
Arrays.sort(chrary);
key=new String(chrary);
hasht.put(key,ary[i]);
}
Enumeration iterator = hasht.elements();
while(iterator.hasMoreElements()) {
String temp = (String)iterator.nextElement();
System.out.println(temp);
}
}
}
Run Code Online (Sandbox Code Playgroud)
PS:输出是defabc jklghi.我想要abcdef defabc ghijkl jklghi.
当括号用于下面的程序输出时
['www.google.com'].
import re
teststring = "href=\"www.google.com\""
m=re.findall('href="(.*?)"',teststring)
print m;
Run Code Online (Sandbox Code Playgroud)
如果在findall函数中删除了括号,则输出为['href="www.google.com"'].
import re
teststring = "href=\"www.google.com\""
m=re.findall('href=".*?"',teststring)
print m;
Run Code Online (Sandbox Code Playgroud)
如果有人解释它是如何工作的将是有帮助的.
这是main.xml的片段.尽管使用了android:layout_width,但它的given属性却丢失了.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/eventlabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_weight="1"
android:paddingBottom="10px"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
有人能指出错误吗?谢谢