对于那些可以在其他语言中体面编码的人来说,快速学习Python有哪些优秀的在线资源?
编辑:如果你能解释为什么你认为资源是有用的,这将有所帮助.
我试图使用awk在bash中舍入几个小数值.例如:如果值为6.79
awk 'BEGIN {rounded = sprintf("%.0f", 6.79); print rounded }'
Run Code Online (Sandbox Code Playgroud)
这让我回报7.
有没有办法我可以舍入到最接近的整数(1,2,3,..),但步骤为0.5(0,0.5,1,1.5,2,2.5 ......)
任何在python或perl中工作的替代方法也都可以.python中的当前方式
python -c "from math import ceil; print round(6.79)"
Run Code Online (Sandbox Code Playgroud)
也返回7.0
这是clang中的错误吗?
这会打印出最大双倍值:
long double a = DBL_MAX;
printf("%Lf\n", a);
Run Code Online (Sandbox Code Playgroud)
它是:
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
这将打印出最大的long double值:
long double a = LDBL_MAX;
printf("%Lf\n", a);
Run Code Online (Sandbox Code Playgroud)
它是:
/* … bigger, but not displayed here. For a good reason. ;-) */
Run Code Online (Sandbox Code Playgroud)
这很清楚.
但是,当我使用算术表达式,即可编译为初始化程序的编译时,我得到了一个令人惊讶的结果:
long double a = 1.L + DBL_MAX + 1.L;
printf("%Lf\n", a);
Run Code Online (Sandbox Code Playgroud)
这仍然打印出DBL_MAX而不是DBL_MAX + 2 !?
如果计算在运行时完成,则相同:
long double b = 2.L;
long double a = DBL_MAX;
printf("%Lf\n", a+b);
Run Code Online (Sandbox Code Playgroud)
仍然是DBL_MAX.
$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.4.0
Thread …Run Code Online (Sandbox Code Playgroud) 我试图在虚拟机上的Ubuntu上安装libxml2-2.9.1.我按照以下链接中的步骤进行操作:http : //www.linuxfromscratch.org/blfs/view/svn/general/libxml2.html http://www.geeksww.com/tutorials/libraries/libxml/installation/ installing_libxml_on_ubuntu_linux.php#评论
我在编译步骤后陷入困境.当我按照任何一个链接时,我会遇到同样的错误.错误是
make[3]: Leaving directory `/home/abhijit/Documents/libxml2-2.9.1/doc/examples'
make[2]: Leaving directory `/home/abhijit/Documents/libxml2-2.9.1/doc'
Making all in example
make[2]: Entering directory `/home/abhijit/Documents/libxml2-2.9.1/example'
CC gjobread.o
CCLD gjobread
make[2]: Leaving directory `/home/abhijit/Documents/libxml2-2.9.1/example'
Making all in xstc
make[2]: Entering directory `/home/abhijit/Documents/libxml2-2.9.1/xstc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/abhijit/Documents/libxml2-2.9.1/xstc'
Making all in python
make[2]: Entering directory `/home/abhijit/Documents/libxml2-2.9.1/python'
make all-recursive
make[3]: Entering directory `/home/abhijit/Documents/libxml2-2.9.1/python'
Making all in .
make[4]: Entering directory `/home/abhijit/Documents/libxml2-2.9.1/python'
CC libxml.lo
libxml.c:14: fatal error: Python.h: No such …Run Code Online (Sandbox Code Playgroud) 我尝试使用-whole-archive/-no-whole-archive选项进行链接。gcc 是 4.1.2。当我尝试:
g++ ...... -Wl, -whole-archive libA.a -Wl, -no-whole-archive libB.a ...
Run Code Online (Sandbox Code Playgroud)
它说-whole-archive并且-no-whole-archive无法识别。当我替换-whole-archive为--whole-archive, 并且与 相同时no-whole-archive,它说
error: unrecognized command line option "-fwhole-archive"
error: unrecognized command line option "-fno-whole-archive"
Run Code Online (Sandbox Code Playgroud)
有谁知道问题出在哪里?
我目前正在开发一个项目,要求我有一个从0.9到1.2的列表,步长为0.01.我尝试了以下方法:
init = float(0.9)
l = []
for i in range(0,31):
l[i]= init + ( float(i) / 100 )
Run Code Online (Sandbox Code Playgroud)
但是,python给了我以下输出:
回溯(最近一次调用最后一次):IndexError中的文件"",第2行:列表赋值索引超出范围
任何人都可以帮我解决这个问题吗?
我最近在考试中被问到为什么我们(String args[ ])只在java中使用main ?为什么我们不在(String args[ ])任何其他编程语言中使用main ?
我正在尝试编写一个脚本来告诉您给定目录中有多少个文件和多少个目录。
这是我编写的脚本,但输出始终是“文件数是”。和“目录数是。”
这是我的代码:
#!/bin/sh
if [ -d "$@" ]
then
find "$@" -type f | ls -l "$@" | wc -l | echo "Number of files is $@"
find "$@" -type d | ls -l "$@" | wc -l | echo "Number of directories is $@"
fi
Run Code Online (Sandbox Code Playgroud) 我需要在文件中找到和删除70多个字符串.我需要删除字符串出现的文件中的整行.
我知道我可以用sed -i '/string to remove/d' fileA.txt它一次删除一个.但是,考虑到我有70岁以上,这需要一些时间.
有没有办法可以将这些70多个字符串放在一个文件中并逐个浏览它们?或者,如果我创建一个包含字符串的文件,有没有办法比较这两个文件,以便从fileA中删除包含其中一个字符串的任何行?