作为一名工科学生,我想用python制作一个聊天机器人.所以,我搜索了很多,但无法真正找到可以教我的东西,或者给我一些具体信息来构建智能聊天机器人.
我想制作一个聊天机器人,提供类似人类的回应(就像朋友和你聊天一样).我目前期待它只是我笔记本电脑上的一个软件(希望以后在IM,IRC或网站上实现).
所以,我正在寻找一个教程/任何其他信息,这肯定会帮助我完成我的项目.
我在Windows上开发了我的整个项目(Django,Python),并且那里的所有PaaS都使用Linux.
VirtualEnv on Linux:
VirtualEnv_dir /
bin/ activate, activate_this.py
include /
lib /
local /
VirtualEnv of Windows:
VitualEnv_dir /
Include/
Lib /
Scripts/ activate.bat, activate_this.py
Run Code Online (Sandbox Code Playgroud)
因为virtualenv在Windows和Linux中有很多不同.我如何在PaaS上使用我的windows virtualenv?
编辑:
如果我在Windows上,我需要跑call virtualenv_dir/scripts/activate.bat进去.在Linux中,它的东西source virtualenv_dir/bin/activate.
现在,我的repo拥有一个使用Windows生成的virtualenv(使用.bat).当我将repo推送到Linux系统时,我应该如何运行它?(bat文件不起作用!)
我正在使用OpenShift PaaS,我想在Git repo上添加一个virtualenv.我该怎么激活它?
什么是最好的解决方案
这就是代码的方式
with open(pickle_f, 'r') as fhand:
obj = pickle.load(fhand)
Run Code Online (Sandbox Code Playgroud)
这适用于Linux系统,但不适用于Windows.它显示了EOFError.我必须使用rb模式使其在Windows上运行..现在这不适用于Linux.
为什么会这样,以及如何解决?
Firebase JS 库似乎无法与 Twitter API v2 一起使用?
\n我看到以下错误消息。
\nindex.js:1 FirebaseError: Firebase: Failed to fetch resource from \nhttps://api.twitter.com/1.1/account/verify_credentials.json?include_email=true, \nhttp status: 403, \nhttp response: {"errors":[\n {"message":"You currently have Essential access which includes access \n to Twitter API v2 endpoints only. If you need access to this endpoint, \n you\xe2\x80\x99ll need to apply for Elevated access via the Developer Portal. \n You can learn more here: \n https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve","code":453}]}\nRun Code Online (Sandbox Code Playgroud)\n <div class="internal-wrapper row-fluid">
<div class="Header span12">
<div class="HeaderTitle span6"></div>
<div class="span6"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,当我在内部包装器上填充时,我期待填充对整个网格产生影响!在里面.但是正在发生溢出(我认为,正确的填充不起作用)
.internal-wrapper {
padding-left: 30px;
padding-right: 30px;
}
Run Code Online (Sandbox Code Playgroud)

下面的蓝色栏代表Header班级.绿色框表示填充!所以,它发生在左边但不是正确的
我正在尝试在AWS Elastic Beanstalk上部署我的应用程序.我收到此错误,完全无法查看问题所在.
以下是代码中的代码 .ebextensions/mysite-env.config
packages:
yum:
python-devel: []
postgresql-devel: []
container_commands:
01_syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
02_createadmin:
command: "scripts/createadmin.py"
leader_only: true
option_settings:
- option_name: WSGIPath
namespace: "aws:elasticbeanstalk:container:python"
value: "mysite/wsgi.py"
- option_name: DJANGO_SETTINGS_MODULE
value: "mysite.settings"
Run Code Online (Sandbox Code Playgroud)
经过几次尝试,我发现了一些东西
requirements.txt在root 之后运行sshEC2实例来安装(奇怪)问题[1]是,为了psycopg2安装,我需要上面提到的包.那么,我该如何先安装它们呢?
当我运行这些设置时,我收到以下错误:
[2014-11-19T09:45:19.819Z] INFO [6703] - [CMD-AppDeploy/AppDeployStage0/EbExtensionPreBuild] : Activity execution failed, because: command failed with error code 1: Error occurred during build: Yum does not have postgresql-devel available for installation (Executor::NonZeroExitStatus) …Run Code Online (Sandbox Code Playgroud) python django amazon-ec2 amazon-web-services amazon-elastic-beanstalk
C:
# include <stdio.h>
main()
{
int i;
for (i=0; i<10; i++)
{
if (i>5)
{
i=i-1;
printf("%d",i);
}
}
}
Run Code Online (Sandbox Code Playgroud)
蟒蛇:
for i in range(10):
if i>5: i=i-1
print(i)
Run Code Online (Sandbox Code Playgroud)
当我们编译C代码时,它会永远进入无限循环打印5,而在Python中却没有,为什么不呢?
Python输出是:
0 1 2 3 4 5 5 6 7 8
我正在做一个难题,我必须处理订单数量10 ^ 18.但是,我发现python无法在所有区域处理非常大的数字.
具体来说,如果我们分配一个= 1000000000000000000(10 ^ 18)并进行基本的算术运算(+, - ,/,*),它的响应.但是,当我在range()中使用它时,它显示OverflowError
>>> a = 1000000000000000000
>>> a/2
500000000000000000L
>>> a*2
2000000000000000000L
>>> a+a
2000000000000000000L
>>> a*a
1000000000000000000000000000000000000L
>>> range(a)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
range(a)
OverflowError: range() result has too many items
>>> xrange(a)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
xrange(a)
OverflowError: Python int too large to convert to C long
Run Code Online (Sandbox Code Playgroud)
我使用的是Python 2.7.
我想在python 2.7中使用inbuild函数来完成它.那可能吗?
由于RedHat openshift不支持Python 2.7,我选择使用自己动手(DIY)应用程序.
我能够使用一个惊人的教程成功安装python 2.7,setuptools,PIP .现在我想设置一个VirtualEnv并在其中安装Django和其他库.
那么,有没有类似的(如上所述:一步一步的过程)教程配置?
这是我的代码
<script type="text/javascript">
$(document).ready(function() {
$('#spc-comment-flag-form').submit(function() {
$.ajax({
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(data) {
if( data['error'] == false) {
var msg = 'We got your flag. Our moderators will now look into it. You may close the window now!';
$('#spc-comment-flag-response').html(msg);
}
else {
$('#spc-comment-flag-response').html(data);
}
},
});
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
编辑
在服务器端它的东西是这样的:
@csrf_protect
@login_required
def flag(request, comment_id, next=None):
if not request.is_ajax():
raise Http404
data = {}
if request.method == 'POST':
...
data = simplejson.dumps(data)
return …Run Code Online (Sandbox Code Playgroud)