
python
dongxq725
这个作者很懒,什么都没留下…
展开
-
python 获取yahoo财经数据的问题
在使用python获取yahoo财经数据时,spyder报错,ImportError: cannot import name quotes_historical_yahoo解决方法,将import quotes_historical_yahoo 修改为 import quotes_historical_yahoo_ochl原创 2017-02-21 15:10:31 · 3111 阅读 · 0 评论 -
ValueError: Variable rnnlm/multi_rnn_cell/cell_0/basic_lstm_cell/kernel already exists, disallowed.
在使用语言模型训练完成之后,在生成的时候,需要使用while循环多次调用生成多句。报错:ValueError: Variable rnnlm/multi_rnn_cell/cell_0/basic_lstm_cell/kernel already exists, disallowed.解决方法:在构建图的代码块上加上with tf.Graph().as_default():with ...原创 2018-07-27 14:59:44 · 1638 阅读 · 0 评论 -
leetcode unsolve
1.Determine whether an integer is a palindrome. Do this without extra space.class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool原创 2018-01-16 14:59:53 · 351 阅读 · 0 评论 -
os.exec call formats
os.execv(program, commandlinesequence)The basic “v” exec form is passed an executable program’s name, along with a listor tuple of command-line argument strings used to run the executable (that转载 2017-09-13 09:06:08 · 214 阅读 · 0 评论 -
python numpy
numpy可以接受传进来的任何序列将其转换成array对象同时也可以通过zeros和ones分别可以创建指定长度或形状的全0或全1数组:In [2]: np.zeros(10)Out[2]: array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])In [4]: np.ones((2,3))Out[4]: array原创 2017-08-11 09:54:26 · 380 阅读 · 0 评论 -
python spicy.hierarchy 实现聚类
特别好的一个使用scipy.hierarchy 实现聚类画dendrogram图的博客https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/#Perform-the-Hierarchical-Clustering原创 2017-08-14 16:00:55 · 1410 阅读 · 0 评论 -
Python程序执行
Python字节码不是机器的二进制代码,而是特定于Python的一种表现形式,这就是Python代码无法运行得像C或者C++代码一样快的原因。Python的传统运行执行模式:录入的源代码转换为字节码,之后字节码在Python虚拟机中运行。代码被自动编译,之后再解释,如图Python的编译器总是在程序运行时出现,并且是运行程序系统的一部分,不需要提前编译原创 2017-02-24 16:05:03 · 341 阅读 · 0 评论 -
Python中拷贝问题
拷贝需要注意:无条件分值的分片以及字典的copy方法只能做到顶层复制,不能够复制嵌套的数据结构。 如果需要一个深层嵌套的数据结构的完整的、完全独立的拷贝,需要使用标准的copy模块——包括import copy语句,并使用 X = copy.deepcopy(Y) #对任意嵌套对象Y做完整的复制。 这个语句能完整递归遍历对象来复制所有的组成部分。原创 2017-03-07 17:36:18 · 386 阅读 · 0 评论 -
Python2x和3x字典比较
Python2x版本中对于字典比较中可以直接使用运算符来进行比较两个字典,根据键值。在Python2x中: 但是在Python3x版本中对于字典已经取消了之前用运算符比较的方式,而是使用items字典方法和sorted字典方法 Python3x中原创 2017-03-10 21:21:10 · 372 阅读 · 0 评论 -
python字典排序
因为字典不是序列,它并不包含从左至右的顺序。也就是说如果我们建立一个字典,并将它打印出来的时候,它的建或许会跟我们输入的顺序不一样。解决的办法有两个;1.使用列表的sort函数D = {'a':1,'b':2,'c':3}print Dks = list(D.keys())ks.sort()print ksfor key in ks: print(key,'=原创 2017-02-25 20:03:25 · 324 阅读 · 0 评论 -
python学习记录1
使用exec(open('module.py').read())内置函数调用,是从交互提示模式启动文件而不必导入以及随后的重载的一种方法,每次exec都运行文件的最新版本。 但是这个有个缺点就是可能会对当前使用的变量有覆盖的可能性。 假如当前变量x=10,如果exec执行的文件也有x变量,并且有不同的值,那么之前x的值会被改写 在对列表进行操作时,如果原创 2017-02-25 11:59:52 · 292 阅读 · 0 评论 -
导入json文件报错,TypeError: expected string or buffer
使用https://www.cnblogs.com/biangbiang/archive/2013/01/21/2869581.html 方法解决,主要内容是:用字符串符值以后,python会把双引号转换为单引号>>> s={"username":"admin","password":"password","tenantid":""转载 2018-10-30 16:02:27 · 1625 阅读 · 0 评论