- 博客(6)
- 资源 (5)
- 收藏
- 关注
原创 python 中的相互import问题
之前用C语言写作业的时候,偶尔会遇到文件相互引用导致不能编译的问题,那么Python中是否会遇到这种情况呢 # a.py import b name = 'a' print b.name # b.py import a name = 'b' print a.name 结果是AttributeError: 'module' object has no attribute 'name'
2013-10-28 14:54:40 5183
原创 python Tkinter的image不能显示的问题
Tkinter是python自带的一个图形库,可以提供一些简单的图形功能 最近使用Tkinter的Canvas绘图的时候出现了一个问题
2013-10-18 21:48:31 20427 10
原创 python中的is、==和cmp()
从官方文档上看 The operators ``is`` and ``is not`` test for object identity: ``x is y`` is true if and only if *x* and *y* are the same object. ``x is not y`` yields the inverse truth value. cmp(.
2013-10-13 18:31:54 1017
原创 c++词法分析器
将词法分析结果放入vector向量中,为语法分析做准备 // MyLex.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include #include using namespace std; typedef struct{ int syn; char name[10]; double value; } TOK
2013-10-12 22:04:58 1335
原创 python的decode和encode
python 内置的文字编码是utf8 decode 的作用是将其他编码转为utf8,如str.decode('gbk')将gbk编码转为utf8 encode 的作用将utf8编码转为其他编码,如str.encode('gbk')将utf8转为gbk
2013-10-08 16:42:09 1208 3
原创 python中的全局变量
最近使用python过程中,发现使用全局变量时有时得声明global,有时不用,很郁闷,上网查了下资料,然后对比python的官方文档,发现原来global的作用是在给全局变量赋值之前声明,否则变量会被识别为局部变量。 比如 a=0 def test1(): print a#输出0 def test2(): a=1 print a#输出1 def test
2013-10-04 22:32:17 853
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人