当我想print在Python中执行命令并且我需要使用引号时,我不知道如何在不关闭字符串的情况下执行此操作.
例如:
print " "a word that needs quotation marks" "
Run Code Online (Sandbox Code Playgroud)
但是当我尝试做我上面做的事情时,我最终关闭了字符串,我不能把我需要的字放在引号之间.
我怎样才能做到这一点?
我正在尝试为我的CS类编译一个C程序.我的Mac上安装了命令行工具,所以我可能有OpenGL.程序描述是为Ubuntu制作的,它说我可以使用以下方法编译:
gcc -Wall -ansi -pedantic -O2 main.o graphic.o imagem.o io.o -o ep2 -lGL -lGLU -lglut
Run Code Online (Sandbox Code Playgroud)
我跑了,它说:
ld: library not found for -lGL
Run Code Online (Sandbox Code Playgroud)
我应该使用什么标志?我该怎么办?
我有以下内容struct:
typedef struct cell Cell;
struct cell {
int value;
int *nextcell;
};
Run Code Online (Sandbox Code Playgroud)
我有以下功能来释放链表:
void freelist(Cell *beginning)
{
Cell *thisCell = beginning;
Cell *NextCell = beginning->nextcell;
while (thisCell != NULL)
{
NextCell = thisCell->nextcell;
free(thisCell);
thisCell = NextCell;
}
/* Here comes my question. Do I need to free the following variables? */
free(beginnig);
free(thisCell);
free(NextCell);
}
Run Code Online (Sandbox Code Playgroud) 所以...我在我的主要上有一个动态分配的数组:
int main()
{
int *array;
int len;
array = (int *) malloc(len * sizeof(int));
...
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
我还想构建一个函数,用这个动态分配的数组做一些事情.到目前为止我的功能是:
void myFunction(int array[], ...)
{
array[position] = value;
}
Run Code Online (Sandbox Code Playgroud)
如果我将其声明为:
void myFunction(int *array, ...);
Run Code Online (Sandbox Code Playgroud)
我还能做到:
array[position] = value;
Run Code Online (Sandbox Code Playgroud)
或者我将不得不这样做:
*array[position] = value;
Run Code Online (Sandbox Code Playgroud)
...?
此外,如果我正在使用动态分配的矩阵,哪一个是声明函数原型的正确方法:
void myFunction(int matrix[][], ...);
Run Code Online (Sandbox Code Playgroud)
要么
void myFunction(int **matrix, ...);
Run Code Online (Sandbox Code Playgroud)
...?
我正在尝试在python中创建一个算法,要求您插入一个数字,然后从插入的数字打印数百,数十和单位.
我想要做的是从与数百个对应的数字中提取字符并将其打印为数百个,以及数十个单位.
例如,我到目前为止尝试做的是:
number = 321
print 'Hundreds: ', number[1]
Run Code Online (Sandbox Code Playgroud)
但是,当我试图运行它时,我收到了消息:
TypeError: 'int' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
做我想做的事是不可能的吗?
所以,我想在语句的末尾打印一个带有感叹号的字符串,但在最后一个单词和感叹号之间没有任何空格.例如:
name = raw_input('Insert your name: ')
Run Code Online (Sandbox Code Playgroud)
现在,我希望python打印这样的东西:
你的名字是约翰!
所以,我输入:
print 'Your name is', name, '!'
Run Code Online (Sandbox Code Playgroud)
它让我回报:
你的名字是约翰!
我想要做的是删除"约翰"和感叹号之间的空格.
有任何想法吗?