任何人都可以推荐一些简单的代码来设置一个简单的JSON RPC客户端和服务器使用twisted?
我找到了txJSON-RPC,但我想知道是否有人有一些使用这些anc的经验可以推荐一些东西.
我想'以这种格式解析日期,但忽略字符串的一部分.'星期三,1770年10月27日22:17:00 GMT'从我收集的信息来看,datetime不能很好地支持时区.哪个好,我真的只想忽略字符串的时区部分,而不必对其进行字符串操作.有什么我可以用下面替换%Z来说"这里有任何字符串"并解析日期吗?另外,我不明白为什么它会解析PST,GMT等时区而不是EST.在任何情况下它似乎都不附加tzinfo,不确定它真正寻找%Z部分的字符串类型.
>>> import datetime
>>> y = datetime.datetime.strptime('Wed, 27 Oct 1770 22:17:00 GMT', '%a, %d %b %Y %H:%M:%S %Z')
>>> y = datetime.datetime.strptime('Wed, 27 Oct 1770 22:17:00 PST', '%a, %d %b %Y %H:%M:%S %Z')
>>> y = datetime.datetime.strptime('Wed, 27 Oct 1770 22:17:00 EST', '%a, %d %b %Y %H:%M:%S %Z')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/brazil-pkg-cache/packages/Python/Python-2.5.1.17.1/RHEL5_64/DEV.STD.PTHREAD/build/lib/python2.5/_strptime.py", line 331, in strptime
(data_string, format))
ValueError: time data did not match format: data=Wed, 27 Oct 1770 …Run Code Online (Sandbox Code Playgroud) 我正在使用io模块的输出流并写入文件.我希望能够检测到何时将1G数据写入文件然后开始写入第二个文件.我似乎无法弄清楚如何确定我写入文件的数据量.
有内置的东西io吗?或者我可能需要在每次手动写入前计算字节数?
我按照这些教程设置了一个Hello World Android应用程序.但是当我创建一个新的java项目时,我无法选择一个构建目标.它只是说目标选择框中没有可用的目标.我已经确认我没有在这里描述的UI问题(http://blog.rowancrane.com/2009/12/27/eclipse-new-android-project-cant-select-build-type-target),我实际上在框中有一条消息说没有目标而不是空框.我也使用1920x1080 res.
我猜测eclipse只是不知道我的Android目标?我将它们安装在android SDK管理器中,并在Android SDK管理器中看到它们列在已安装的软件包下(1.1,1.6,...,2.2)
http://fyi.oreilly.com/2009/02/setting-up-your-android-develo.html http://developer.android.com/resources/tutorials/hello-world.html
关于如何创建项目并开始使用的任何建议?提前致谢
我想知道是否有人知道在python谷歌应用引擎上生成GUID的好方法.我觉得人们使用的方式很简单,你会建议什么.
我在ec2上使用亚马逊Linux的第一个默认AMI,似乎无法安装pyOpenSSL.我试过:sudo wget http://launchpad.net/pyopenssl/main/0.11/+download/pyOpenSSL-0.11.tar.gz&& easy_install pyOpenSSL-0.11.tar.gz.
Results were:
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/lib/python2.6/site-packages/test-easy-install-21047.write-test'
Run Code Online (Sandbox Code Playgroud)
还试过:结果是:sudo python setup.py build
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
running build
running build_py
running build_ext
building 'OpenSSL.crypto' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions …Run Code Online (Sandbox Code Playgroud) 我按照以下说明运行升级程序。然后在尝试在android上启动项目后,通过运行“ react-native run-android”,弹出React Packager终端窗口,并显示以下错误。该应用程序已加载到我的Android手机上,但只是说服务器上出现500错误。我认为这是此错误的根本原因。
看来奇怪的是setupBabel.js是一个文件,并且在正确的文件夹中,但是此错误表明没有这样的目录,而不是文件。有点奇怪
React packager ready.
Loading dependency graph, done.
error: bundling: UnableToResolveError: Unable to resolve module `../setupBabel` from `/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/index.js`: Directory /Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/setupBabel doesn't exist
at ResolutionRequest._loadAsDir (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:572:13)
at tryResolveSync (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:411:18)
at tryResolveSync (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:89:12)
at ResolutionRequest._resolveFileOrDir (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:409:12)
at ResolutionRequest._resolveNodeDependency (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:417:19)
at ResolutionRequest.resolveDependency (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:135:29)
at dependencyNames.map.name (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:142:59)
at Array.map (native)
at ResolutionRequest.resolveModuleDependencies (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:142:42)
at Promise.resolve.then (/Users/amato/git_react-native-web-hello-world/react-native-web-hello-world/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:179:21)
Bundling `index.js` 0.0% (0/20), failed.
Run Code Online (Sandbox Code Playgroud)
这是我的package.json
{
"name": "ReactNativeWebHelloWorld",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"ios-bundle": "react-native bundle --dev …Run Code Online (Sandbox Code Playgroud) 来自http://docs.python.org/library/time.html:
time.mktime(t):这是localtime()的反函数.它的参数是struct_time或完整的9元组(因为需要dst标志;如果它是未知的,则使用-1作为dst标志),它以本地时间而不是UTC表示时间.它返回一个浮点数,以便与time()兼容.如果输入值不能表示为有效时间,则会引发OverflowError或ValueError(这取决于Python或底层C库是否捕获到无效值).它可以生成时间的最早日期取决于平台.
这表示您需要在当地时间而不是UTC指定时间元组.但是,我想用UTC指定; 我不想在盒子上使用本地时区.
有什么方法可以从datetime到时间戳,其中时间被视为UTC?当我转换为时间戳和从时间戳转换时,我希望能够将所有内容保存在规范化的UTC表单(datetime对象)中.
我希望能够做这样的事情,让x和y出现相同:
y = datetime.datetime.utcfromtimestamp(time.mktime(x.timetuple()))
x = dateutil.parser.parse('Wed, 27 Oct 2010 22:17:00 GMT')
stamp = time.mktime(x.timetuple())
y = datetime.datetime.utcfromtimestamp(stamp)
x
datetime.datetime(2010, 10, 27, 22, 17, tzinfo=tzutc())
y
datetime.datetime(2010, 10, 28, 6, 17)
Run Code Online (Sandbox Code Playgroud) 我注意到Twisted依赖于Zope.我发现当我尝试安装Zope时,运行后,./ configure它告诉我我需要使用python2.4(而不是我希望使用的python 2.5+).
但是,我已经看到一些教程和指南建议使用python 2.5 for Twisted.所以我一般都很困惑.有没有人设置这个并运行一些使用zope的twsited web示例?你用的是什么版本的python?你有什么安装指南吗?
我想存储整数列表(用户ID),我应该使它们成为字符串并使用StringListProperty,或者只使用ListProperty,我想知道什么是更优化的,异构ListProperty的特定StringListProperty(当仅与Integers一起使用时) ).
我需要将用户添加到列表中,直到达到一定数量,然后我为这些用户创建一个组实例(在一个单独的实体组中).