
Python
CFAKdiv2
好学生
展开
-
python导入别的目录下的模块
网上有很多__init__.py的方法。其实可以这样:假设另外的目录下有个文件yes.py他的完整路径是/home/baby/yes.py那么可以在任意位置如下导入import syssys.path.append('/home/baby')import yes原创 2020-07-21 23:17:52 · 219 阅读 · 0 评论 -
使用Sage生成 凸包不等式
新建一个a.sage。以下的代码就生成了Points的凸包不等式。Points = [[0,2],[1,-32],[0,20],[23,233]]poly = Polyhedron ( vertices = Points)for l in poly.inequality_generator(): print(l)保存,终端运行:sage a.sgae > temp_res.txt输出的格式我们不是很满意,想转化成元组的格式vim trans2tuple.pyw原创 2020-07-20 22:58:45 · 1295 阅读 · 4 评论 -
第一天玩Python,列表~
今天第一天玩Python,接触了列表,有C++基础这个应该很简单。不过它的成员函数还是挺多的number = [1,2,4,5]print(number)number.append(3)print('number.append(3)')print(number)number.sort()print('number.sort()')print(number)number....原创 2018-05-28 17:09:26 · 341 阅读 · 0 评论 -
Python的全局变量竟然不用先声明
def discounts(price,rate) : final_price = price * rate print(old_price) return final_priceold_price = 120.0rate = 0.9new_price = discounts(old_price,rate)print(new_price)这个程序竟然没错,明明o...原创 2018-05-28 19:08:27 · 4332 阅读 · 2 评论