I am having trouble setting up my project skeleton because now the guide is asking me to use Linux only commands and I'm on Windows. This entire guide up until this project has had no compatibility issues with Windows until a line of code in exercise 46.
我在设置项目框架时遇到了麻烦,因为现在指南要求我使用仅Linux命令,而且我在Windows上。直到这个项目之前的整个指南与Windows没有兼容性问题,直到练习46中的一行代码。
I was able to do this:
我能够做到这一点:
$ mkdir -p projects
$ cd projects/
$ mkdir skeleton
$ cd skeleton
$ mkdir bin NAME tests docs
I was not able to do this:
我无法做到这一点:
$ touch NAME/__init__.py
$ touch tests/__init__.py
('touch' is not recognized as an internal or external command, operable program or batch file.)
('touch'不被识别为内部或外部命令,可操作程序或批处理文件。)
I understand this isn't even the hard part of this exercise but the author doesn't provide any words at all about 'touch' or that he is suddenly using Linux.
我知道这甚至不是这个练习的难点,但作者并没有提供任何关于“触摸”的话或者他突然使用Linux。
6 个解决方案
#1
8
To touch
a file is to simply create an empty file with that name. Use notepad and save a file with the name with no contents in it, making sure that you are in the proper directory.
触摸文件只是创建一个具有该名称的空文件。使用记事本并保存名称中没有内容的文件,确保您位于正确的目录中。
For an answer to why would you want the __init__.py
file in the first place, see this question.
要获得为什么首先需要__init__.py文件的答案,请参阅此问题。
#2
5
> touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.
I recommend you get hold of GnuWin32, the GNU tools compiled for Windows, and then you can use the same commands as your guide. Running Windows does not mean you cannot also use the command line like a *nix user.
我建议您掌握为Windows编译的GNU工具GnuWin32,然后您可以使用与指南相同的命令。运行Windows并不意味着您也不能像* nix用户那样使用命令行。
#3
2
Touch just creates a new empty text file with the name you specify. I'm a linux guy but i might try this if I wanted a Windows command-line option.
触摸只是使用您指定的名称创建一个新的空文本文件。我是一个Linux家伙,但如果我想要一个Windows命令行选项,我可能会尝试这个。
You could always just right click in explorer to create a new text document. Or save an empty text file in notepad.
您可以随时右键单击资源管理器以创建新的文本文档。或者在记事本中保存一个空文本文件。
#4
2
I would recommend skimming through Zed Shaw's Learn the CLI the Hard Way, which provides his recommended way of interacting with the command-line for your platform.
我建议浏览Zed Shaw的“学习CLI艰难之路”,它提供了与平台命令行交互的推荐方法。
In the case of Windows, he recommends you use Powershell, which has the New-Item command:
对于Windows,他建议您使用Powershell,它具有New-Item命令:
> cd temp
> New-Item iamcool.txt -type file
> ls
Directory: C:\Users\zed\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM iamcool.txt
#5
1
To touch
files that don't exist in windows you can also just redirect a no op to a file. Note do not do this on an existing file as it will overwrite it!
要触摸Windows中不存在的文件,您还可以将no操作重定向到文件。注意不要在现有文件上执行此操作,因为它会覆盖它!
In your case this would be:
在你的情况下,这将是:
: > NAME/__init__.py
: > tests/__init__.py
#6
1
I recommend cygwin. It has all unix command line tools like bash-shell, touch, cat, sed, awk,... Since the DOS-box is not nice, I recommend to install rxvt. It is like a xterm on unix/linux.
我推荐cygwin。它有所有unix命令行工具,如bash-shell,touch,cat,sed,awk,...由于DOS框不好,我建议安装rxvt。它就像unix / linux上的xterm。
#1
8
To touch
a file is to simply create an empty file with that name. Use notepad and save a file with the name with no contents in it, making sure that you are in the proper directory.
触摸文件只是创建一个具有该名称的空文件。使用记事本并保存名称中没有内容的文件,确保您位于正确的目录中。
For an answer to why would you want the __init__.py
file in the first place, see this question.
要获得为什么首先需要__init__.py文件的答案,请参阅此问题。
#2
5
> touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.
I recommend you get hold of GnuWin32, the GNU tools compiled for Windows, and then you can use the same commands as your guide. Running Windows does not mean you cannot also use the command line like a *nix user.
我建议您掌握为Windows编译的GNU工具GnuWin32,然后您可以使用与指南相同的命令。运行Windows并不意味着您也不能像* nix用户那样使用命令行。
#3
2
Touch just creates a new empty text file with the name you specify. I'm a linux guy but i might try this if I wanted a Windows command-line option.
触摸只是使用您指定的名称创建一个新的空文本文件。我是一个Linux家伙,但如果我想要一个Windows命令行选项,我可能会尝试这个。
You could always just right click in explorer to create a new text document. Or save an empty text file in notepad.
您可以随时右键单击资源管理器以创建新的文本文档。或者在记事本中保存一个空文本文件。
#4
2
I would recommend skimming through Zed Shaw's Learn the CLI the Hard Way, which provides his recommended way of interacting with the command-line for your platform.
我建议浏览Zed Shaw的“学习CLI艰难之路”,它提供了与平台命令行交互的推荐方法。
In the case of Windows, he recommends you use Powershell, which has the New-Item command:
对于Windows,他建议您使用Powershell,它具有New-Item命令:
> cd temp
> New-Item iamcool.txt -type file
> ls
Directory: C:\Users\zed\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM iamcool.txt
#5
1
To touch
files that don't exist in windows you can also just redirect a no op to a file. Note do not do this on an existing file as it will overwrite it!
要触摸Windows中不存在的文件,您还可以将no操作重定向到文件。注意不要在现有文件上执行此操作,因为它会覆盖它!
In your case this would be:
在你的情况下,这将是:
: > NAME/__init__.py
: > tests/__init__.py
#6
1
I recommend cygwin. It has all unix command line tools like bash-shell, touch, cat, sed, awk,... Since the DOS-box is not nice, I recommend to install rxvt. It is like a xterm on unix/linux.
我推荐cygwin。它有所有unix命令行工具,如bash-shell,touch,cat,sed,awk,...由于DOS框不好,我建议安装rxvt。它就像unix / linux上的xterm。