随笔分类 -  python

is in
摘要:isTrue,isstring,isdicta=[1,2,3,4];if2ina:print'yes' 阅读全文

posted @ 2014-04-23 16:42 人生苦短,gopython 阅读(168) 评论(0) 推荐(0)

python tab键
摘要:# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind('tab: complete')# history filehistfile = os.path.join(os.environ['HOME'], '.pythonhistory')try: readline.read_history_file(histfile)except IOError: pa 阅读全文

posted @ 2014-03-23 18:28 人生苦短,gopython 阅读(345) 评论(0) 推荐(0)

Python
摘要:文件内容替换for line in fileinput.input("filepath",inplace = 1): line = line.replace("oldetxt","newtxt") print line修改某行with open("foo.txt","r+") as f: old = f.read() f.seek(0) f.write("new line\n" + old)line before 阅读全文

posted @ 2014-03-19 21:45 人生苦短,gopython 阅读(140) 评论(0) 推荐(0)

在python交互模式使用tab键补齐代码
摘要:importrlcompleter,readlinereadline.parse_and_bind('tab:complete') 阅读全文

posted @ 2014-03-19 21:35 人生苦短,gopython 阅读(209) 评论(0) 推荐(0)

导航