科学网

 找回密码
  注册
Python3: for loop
刘洋洋 2017-5-31 21:22
脚本: 注释纠正:range(1,10,2) returns the intergers 1 to 9 with the step of 2. 输出结果:
个人分类: Python|1897 次阅读|没有评论
Python3: while loop
刘洋洋 2017-5-31 21:09
while (): else: # else部分可省略 脚本: 输出结果: while True - 使程序进入死循环。常与 break语句 连用,用以结束循环。 try-except语句见博文: Python: 异常处理try-except语句和with语句 http://blog.sciencenet.cn/blog-3031432-1059523.html
个人分类: Python|2031 次阅读|没有评论
python 神器
刘洋洋 2017-5-31 18:00
1. Jupyter Notebook 2. Anaconda
个人分类: Python|1554 次阅读|没有评论
Python3: if statement
刘洋洋 2017-5-31 16:38
if (): elif (): # elif部分可省略 else: # else部分可省略 脚本示例: 注: 1. 函数头 if/elif/else 以冒号:结尾 2. 函数体 print 前需要缩进(4个空格),否则会报错:IndentationError: expected an indented block (代码缩进). 输出结果: a is greater than b str1 i ...
个人分类: Python|2200 次阅读|没有评论
Emacs: 系列教程 & GNU Emacs Reference Card
刘洋洋 2017-5-31 14:49
refcard.pdf https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf 系列中文教程见“璇玑玉衡”的博客: http://www.cnblogs.com/robertzml/tag/Emacs/
个人分类: Emacs|3045 次阅读|没有评论
Python3: 格式化输出 print()
刘洋洋 2017-5-31 04:40
参考: http://blog.csdn.net/lcore/article/details/9057967 print (...) print (value, ..., sep= ' ' , end= 'n' , file=sys.stdout, flush= False ) # n表示换行 name1 = 'Jane' name2 = 'Liz' ...
个人分类: Python|18396 次阅读|没有评论
Python3: 提示输入——input函数
刘洋洋 2017-5-31 03:42
input () ——提示输入,输入对象为string格式,返回值为string格式。 python脚本示例如下: #!/usr/bin/python3 (注:#!后面的路径可通过在terminal中输入which python确定) myname = input ('What is your name?') print ('Hello ' + myname) print (myname + ', Let &# ...
个人分类: Python|16710 次阅读|没有评论
Python3:字符串 str(), repr(), eval()
刘洋洋 2017-5-31 02:51
repr () ——返回对象的string格式,以供交互式解释器(也就是matlab中的command window)读取。 repr (3) '3' repr (3+4) '7' repr ( ' Hi ' ) 'Hi' print ('Hi'+repr(3)) Hi3 str() ——返回对象的strin ...
个人分类: Python|5805 次阅读|没有评论
Linux:在服务器上后台运行程序
刘洋洋 2017-4-3 16:48
See originals: https://www.howtoforge.com/linux_screen 使用SSH连接服务器并进行长时间计算时,经常出现连接意外断开的情形,使得程序运行功亏一篑。为避免这种情况,可以将任务在后台运行。如此,screen命令就应运而生了。 1. 创建一个名为matlab的screen session: screen -S matlab 2. 然后使用 以 ...
个人分类: Linux|3943 次阅读|没有评论
Matlab: 在ollie上激活license
刘洋洋 2017-3-28 18:01
1. 找到Host ID. 对于ollie1: 1) ifconfig 2) 最先出现的那个名字,如eth0,ether后面的码即为Host ID,如a4:bf:01:..:.. 对于专有的nod,如prod-308:1)进入prod-308. salloc --nodelist prod-0308 -pmatlab ...
个人分类: Matlab|2311 次阅读|没有评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-12 19:43

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部