的Gemfile
...
gem 'nokogiri'
...
Run Code Online (Sandbox Code Playgroud)
在控制器中
doc = Nokogiri::HTML(open('http://google.com'))
Run Code Online (Sandbox Code Playgroud)
我收到了一个错误
Errno::ENOENT in SiteController#scrap
No such file or directory - http://google.com
app/controllers/site_controller.rb:6:in `initialize'
app/controllers/site_controller.rb:6:in `open'
app/controllers/site_controller.rb:6:in `scrap'
Run Code Online (Sandbox Code Playgroud)
我尝试删除Gemfile.lock并再次"捆绑安装",但它没有解决我的问题.
rails 2.3.8
红宝石1.9.3p194
我究竟做错了什么?在此先感谢您的帮助
这里有一个插件来支持Intellij IDEA中的underscore.js模板?
现在它看起来像这样:

系统标记<%=未突出显示,html标记突出显示为错误
Django 1.7,PostgreSQL.
我想以UTC格式存储日期时间并将其显示在PST时区中.
我当地时间:上午8:05
UTC时间:凌晨1点05分
PST时间:下午6:05
Django doc:
When support for time zones is enabled, Django stores date and time
information in UTC in the database, uses time-zone-aware datetime objects
internally, and translates them to the end user’s time zone in templates
and forms.
Run Code Online (Sandbox Code Playgroud)
setting.py
USE_TZ = True
TIME_ZONE = 'US/Pacific'
Run Code Online (Sandbox Code Playgroud)
模型领域
created_at = models.DateTimeField(auto_now_add=True)
Run Code Online (Sandbox Code Playgroud)
我创建了新模型,在django admin中显示PST时间(下午6:05).没关系.但如果我这样做:
select created_at from my_table where id = 1;
Run Code Online (Sandbox Code Playgroud)
它显示我当地时间(上午8:05)!所以,我不确定这是存储在UTC时间.
还有一件事.
通常的日期时间字段,我在管理员这个日期设置:2014-10-25 18:00:00
ID于2014年10月25日下午6点在管理员中显示
但是从DB中选择让我看看:
2014-10- 26 08:00:00.0
所以,我绝对不明白发生了什么.我的错误在哪里?
我做了我的第一个基因敲除应用程序http://jsfiddle.net/Pqs7e/
对于显示应用程序部分(书籍部分,关于部分),我使用jquery $(“#id”)。show()。我觉得这是不正确的方法。如何通过viewmodel的机制做到这一点?
我的Python版本是3.5.1
我有一个简单的代码(tests.py):
import unittest
class SimpleObject(object):
array = []
class SimpleTestCase(unittest.TestCase):
def test_first(self):
simple_object = SimpleObject()
simple_object.array.append(1)
self.assertEqual(len(simple_object.array), 1)
def test_second(self):
simple_object = SimpleObject()
simple_object.array.append(1)
self.assertEqual(len(simple_object.array), 1)
if __name__ == '__main__':
unittest.main()
Run Code Online (Sandbox Code Playgroud)
如果我用命令'python tests.py'运行它,我会得到结果:
.F
======================================================================
FAIL: test_second (__main__.SimpleTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 105, in test_second
self.assertEqual(len(simple_object.array), 1)
AssertionError: 2 != 1
----------------------------------------------------------------------
Ran 2 tests in 0.003s
FAILED (failures=1)
Run Code Online (Sandbox Code Playgroud)
为什么会这样?以及如何解决它.我希望每个测试运行都是独立的(每个测试都应该通过),但它并不像我们所看到的那样.
我有一个数字列表:[0,0,1,1,2,2]
我想拥有2个数字的所有组合,我试着用itertools做:
import itertools
a = [0, 0, 1, 1, 2, 2]
combinations = set(itertools.permutations(a, 2))
print(combinations)
# {(0, 1), (1, 2), (0, 0), (2, 1), (2, 0), (1, 1), (2, 2), (1, 0), (0, 2)}
Run Code Online (Sandbox Code Playgroud)
我想将列表中的所有数字用于组合,但是itertools没有这样做.
所以,我想得到这样的结果:
(0, 0), (0, 1), (0, 1), (1, 0), (1, 0) ...
Run Code Online (Sandbox Code Playgroud)
所以,既然我们有两个0和两个1,我们将有两个(0,1)组合等.
在js控制台中我收到错误:
"未捕获错误:无法解析绑定.消息:ReferenceError:未定义new_book;绑定值:value:new_book().name"
我究竟做错了什么?
python ×3
knockout.js ×2
algorithm ×1
combinations ×1
datetime ×1
django ×1
javascript ×1
nokogiri ×1
python-3.x ×1
pytz ×1
ruby ×1
sammy.js ×1
templates ×1
unit-testing ×1