摘要:
一、与直接执行的区别命令行执行.py文件时有两种加载方式:python xxx.py与python -m xxx。这是两种加载py文件的方式:前者叫做直接运行,此时脚本的__name__为'main';后者把模块当作脚本来启动,相当于import,此时脚本的__name__为'xxx'。这种启动方式 阅读全文
posted @ 2020-01-13 16:02
sgggr
阅读(207)
评论(0)
推荐(0)
摘要:
python -c参数,支持执行单行命令/脚本。例: > python -c "import os;print('hello'),print('world')" > python -c "import os;print('hello');print('world')" 注意:要用双引号将命令包起来, 阅读全文
posted @ 2020-01-13 15:46
sgggr
阅读(875)
评论(0)
推荐(0)
摘要:
目录 前言: 程序入口 __name__ __main__.py 文件与 python -m 正文 回到顶部 前言: 朋友眼中你是小明(__name__ == '小明'),你自己眼中你是你自己(__name__ == '__main__'), 你编程很好, 朋友调你去帮他写程序(import 小明, 阅读全文
posted @ 2020-01-13 15:42
sgggr
阅读(355)
评论(0)
推荐(0)
摘要:
%prun -l 7 -s cumulative function() 一.基本性能分析 1.cProfile模块,输出结果按函数名排序. cProfile记录的是各函数调用的起始和结束时间,并依次计算总时间 python -m cProfile XX.py -s指定排序规则: python -m 阅读全文
posted @ 2020-01-13 14:59
sgggr
阅读(455)
评论(0)
推荐(0)
摘要:
参考: http://www.cnblogs.com/yyxayz/p/4033736.html http://www.pythontab.com/html/2013/pythonjichu_0918/568.html 《Machine Learning in Action》第二章 ######## 阅读全文
posted @ 2020-01-13 14:27
sgggr
阅读(693)
评论(0)
推荐(0)