最近在win7上为我的python项目安装了Anaconda(1.9)
安装完成后,我在这个页面中构建了一个带有指令的python 3支持环境.我的下一个任务是使用内置批处理文件自动激活我的python环境.
我在开始菜单中找到的[Anaconda命令提示符]快捷方式中使用了该命令.它运行一个名为[ anaconda.bat ] 的批处理文件
在观察批处理文件后,我意识到它似乎能够获取一个输入参数,该参数应该是我想要激活的环境.所以我复制了快捷方式并将其修改为
C:\Windows\System32\cmd.exe /k "C:\Anaconda\Scripts\anaconda.bat py3k"
Run Code Online (Sandbox Code Playgroud)
然后我双击新的快捷方式,它打开了一个新的命令窗口但是...指定的环境没有激活!
@echo off
rem +===========================================================================
rem | Initialisation
rem +===========================================================================
verify bogus-argument 2>nul
setlocal enableextensions enabledelayedexpansion
if ERRORLEVEL 1 (
echo error: unable to enable command extensions
goto :eof
)
for %%i in ("%~dp0..\envs") do (
set ANACONDA_ENVS=%%~fi
)
if not "%1" == "" (
if not exist "%ANACONDA_ENVS%\%1\python.exe" (
echo No environment named "%1" exists in %ANACONDA_ENVS%
goto :eof
)
set ANACONDA_ENV_NAME=%1
set ANACONDA=%ANACONDA_ENVS%\%1
title …Run Code Online (Sandbox Code Playgroud) 我试图更多地了解C中的char指针,但有一件事让我感到兴奋.
假设我想将char指针传递给函数并更改指针所代表的值.一个例子如下:
int Foo (char *(&Msg1), char* Msg2, char* Msg3){
char *MsgT = (char*)malloc(sizeof(char)*60);
strcpy(MsgT,"Foo - TEST");
Msg1 = MsgT; // Copy address to pointer
strcpy(Msg2,MsgT); // Copy string to char array
strcpy(Msg3,MsgT); // Copy string to char pointer
return 0;
}
int main() {
char* Msg1; // Initial char pointer
char Msg2[10]; // Initial char array
char* Msg3 = (char*)malloc(sizeof(char) * 10); // Preallocate pointer memory
Foo(Msg1, Msg2, Msg3);
printf("Msg1: %s\n",Msg1); // Method 1
printf("Msg2: %s\n",Msg2); // Method 2 …Run Code Online (Sandbox Code Playgroud)