我有这个代码(用BS4文档编写):
from bs4 import BeautifulSoup
Run Code Online (Sandbox Code Playgroud)
当我运行脚本(使用python3)时,我收到错误:
ImportError: No module named 'bs4'
Run Code Online (Sandbox Code Playgroud)
所以安装BeatifulSoup:
sudo pip install BeatifulSoup4
Run Code Online (Sandbox Code Playgroud)
但是当我再次尝试运行脚本时,我得到了同样的错误.确实BS4安装在:
BeautifulSoup4 in /usr/local/lib/python2.7/dist-packages
Run Code Online (Sandbox Code Playgroud)
但我想安装并使用它与python3.3(因为有其他模块不使用python2.7).
我尝试过:
virtualenv --python=/usr/bin/python2.7 /usr/bin/python3.3
Run Code Online (Sandbox Code Playgroud)
然后再次安装BS4,但没有解决.
任何线索?提前致谢
我犯了这个错误:
DbfError: unable to modify fields individually except in with or Process()
Run Code Online (Sandbox Code Playgroud)
怎么解决?
这是我的代码:
with dbf.Table("aa.dbf") as table:
for record in table:
record[3] = 200
Run Code Online (Sandbox Code Playgroud) 因此,我使用 Visual Studio 2017 模板“ASP.NET Core Web 应用程序”和 Angular 创建了一个示例项目。我将默认创建的 package.json 更新为最新模块的版本。运行npm install命令并启动站点后,我收到与 TypeScript 相关的错误。
[at-loader] ./ClientApp/app/components/fetchdata/fetchdata.component.ts:9:12 TS2564 中出现错误:属性“forecasts”没有初始值设定项,并且未在构造函数中明确分配。
Angular 正在开发模式下运行。调用enableProdMode()启用生产模式。client.js:67 [HMR] 已连接 client.js:160 [HMR] 捆绑包有 1 个错误 client.js:161 [at-loader] ./ClientApp/app/components/fetchdata/fetchdata.component.ts:9:12 TS2564:属性“预测”没有初始值设定项,并且未在构造函数中明确分配。
这个错误是很明显的。我做了一些研究,发现了 TS 2.7 的一个新功能: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html
严格的类初始化
TypeScript 2.7 引入了一个名为 --strictPropertyInitialization 的新标志。此标志执行检查以确保类的每个实例属性在构造函数主体中或通过属性初始值设定项进行初始化。例如 ...
这是出现错误的代码
import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'fetchdata',
templateUrl: './fetchdata.component.html'
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
http.get(baseUrl …Run Code Online (Sandbox Code Playgroud) 在项目中工作时,我看到了一个奇怪的行为,我无法理解加载导航属性。
这是一个重现这个“问题”的小例子。

我想加载一年,但不包括公司的数据(导航属性)。
我的代码:
public static Year GetYear(int id)
{
using (var context = new testModelContainer())
{
var result = context.YearSet.FirstOrDefault(c => c.Id == id);
//Company test = context.CompanySet.Where(c => c.Id == id).FirstOrDefault();
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
这将返回我想要的年份,导航属性中没有数据,但是如果我取消注释该行并只执行该行,可能是因为我想知道公司名称或其他什么,它会自动将公司数据包含到公司中年度最佳导航属性。
知道如何防止这种行为吗?出于安全原因,我想避免发送“父母”的数据。
我正在使用 EF 6、.NET 4.5。
我收到一条消息
[Errno 13]权限被拒绝:u'/ home/.../... jpg'当我尝试在django上传文件时.但问题只有在我使用localhost /尝试时才会出现.当我使用localhost:8000运行或调试它时,我没有遇到任何问题.
当我运行脚本来设置我的数据库时,我使用函数创建文件夹.
我的代码:
def handle_uploaded_file(request,f):
user=Users.objects.get(id_u=request.user.id)
url=settings.MEDIA_URL+'images/'+user.mail+'/gallery/'+f.name
fullurl=settings.MEDIA_ROOT+'images/'+user.mail+'/gallery/'+f.name
#comprobar si existe el archivo
if not os.path.exists(fullurl):
destination = open(fullurl, 'wb+')
...
destination.close()
Run Code Online (Sandbox Code Playgroud)
文件夹媒体中的权限.我想将文件上传到'images'文件夹.在这里,我看到其他人没有权限写,但up文件夹有777.那么,为什么我的脚本在创建子文件夹时会更改权限?
4 drwxrwxrwx 3 bernardo www-data 4096 ago 3 09:42 .
4 drwxrwxr-x 11 bernardo www-data 4096 jul 31 12:36 ..
4 drwxrwxr-x 5 bernardo bernardo 4096 ago 3 09:42 images
Run Code Online (Sandbox Code Playgroud)
我的http.config
ServerName localhost
WSGIPythonPath /home/bernardo/workspace/mbosoziales
Alias /media/ /home/bernardo/workspace/mbosoziales/media/
Alias /static/ /home/bernardo/workspace/mbosoziales/static/
<Directory /home/bernardo/workspace/mbosoziales/static>
Order deny,allow
Allow from all
</Directory>
<Directory /home/bernardo/workspace/mbosoziales/media>
Order …Run Code Online (Sandbox Code Playgroud) 我正在使用webpack创建* .js捆绑包
var path = require('path');
var webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
site: [
'./wwwroot/js/site.js',
'./node_modules/jquery/dist/jquery.js',
'./Scripts/jquery.global.js',
'./node_modules/jquery-validation/dist/jquery.validate.js',
'./node_modules/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js',
'./node_modules/popper.js/dist/popper.js',
'./node_modules/bootstrap/dist/js/bootstrap.js',
]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'wwwroot/dist/')
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".css"]
},
plugins: [
new ExtractTextPlugin('../css/bundle.css'),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: …Run Code Online (Sandbox Code Playgroud) 我试图使用库中的pipe3函数,FParsec但我得到一个错误,我不知道如何解决.
鉴于记录
type Point = { x: float; y: float }
Run Code Online (Sandbox Code Playgroud)
和以下解析器
let plistoffloats' =
pipe3 pfloat (pchar ',' .>> spaces) pfloat
(fun first z second -> { x = first; y = second })
Run Code Online (Sandbox Code Playgroud)
我试图实现的是一个解析器,它接收格式的字符串"1.1, 3.7"并返回一个Point
run plistoffloats' "1.1, 3.7"
Run Code Online (Sandbox Code Playgroud)
输入:"1.1, 3.7"
期望的输出:Point = {x = 1.1; y = 3.7;}
错误:
错误FS0030:值限制.值'plistoffloats''被推断为具有泛型类型val plistoffloats':
Parser <Point,'__a>
将'plistoffloats'的参数显式化,或者,如果您不打算将它作为泛型,则添加类型注释.
一个更简单的例子pchar也没有用.
let parsesA = pchar 'a'
Run Code Online (Sandbox Code Playgroud)
错误FS0030:值限制.值'parsesA'被推断为具有泛型类型val parsesA:
Parser<char,'_a> …
有没有办法可以明确定义我定义的新运算符的元素?
我检查了文档但找不到它:https : //docs.microsoft.com/en-us/dotnet/fsharp/language-reference/operator-overloading#creating-new-operators
假设我定义了以下xor运算符:
let (^@) a b =
a <> b
let result = true ^@ false
Run Code Online (Sandbox Code Playgroud)
它工作正常,但以下定义不...
let (@^) (a: bool, b:bool) : bool =
a <> b
Run Code Online (Sandbox Code Playgroud)
我正在尝试从数据库获取文件并将其写入磁盘。该文件存储为 BLOB。
现在我有以下代码:
#!/usr/bin/python
import MySQLdb
db2 = MySQLdb.connect(host="localhost",
user="root",
passwd="root",
db="digit")
cur = db2.cursor()
#get the name of the file
cur.execute("SELECT Name FROM ContentFiles WHERE ID=3")
nombre = cur.fetchone()
#open file and write into.
with open(nombre[0],"wb") as output_file:
cur.execute("SELECT File FROM ContentFiles WHERE ID=3")
ablob = cur.fetchone()
output_file.write(ablob[0])
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。谢谢 :)
我进行了调试,它获取文件并将其写入磁盘,但是当我打开时,它显示错误:
Not a JPEG file: starts with 0x2f 0x39
Run Code Online (Sandbox Code Playgroud) 我正在关注这个 AngularJS+ASP.NET 教程,他们使用了$scope,但我试图用新语法替换过时的用法controller,如这个问题中所述:“AngularJs“控制器作为”语法 - 澄清?”
我所做的目前不起作用。页面在函数$http.get内部调用nextQuestion(),但视图保持不变,只有标题"loading question..."。
我的代码:
JS http://pastebin.com/RfngRuZD
var app = angular.module('QuizApp', [])
app.controller('QuizCtrl', ['$http', function ($http) {
this.answered = false;
this.title = "loading question...";
this.options = [];
this.correctAnswer = false;
this.working = false;
this.answer = function () {
return this.correctAnswer ? 'correct' : 'incorrect';
};
// GET
this.nextQuestion = function () {
this.working = true;
this.answered = false;
this.title = "loading question...";
this.options = …Run Code Online (Sandbox Code Playgroud) 如果用户没有注册,我试图在我的照片库上获得模糊效果.我明白了,但仅限于镀铬.在我的Firefox 14.0.1(linux)中,我无法让它运行起来
我的html模板(我在django下开发)
<h2> Gallerie</h2>
<ul class="galeria" id="imagenes">
{% for image in gallery %}
{% if user.is_authenticated %}
<a rel="prettyPhoto[gallery]" href="{{image.url}}">
<img width="120px" height="120px" alt="{{image.comment}}" src="{{image.url}}"/>
</a>
{% else %}
<img class="blur" alt="{{image.comment}}" src="{{image.url}}"/>
{% endif %}
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
我的site.css
img.blur{
-webkit-filter: grayscale(0.5) blur(10px);
filter: grayscale(0.5) blur(10px);
width:120px;
height:120px;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢 :)
问题:
我想在成功时将部分视图加载到DIV中,但是如果发生错误,我需要重定向到视图主页.问题是重定向到操作也被加载到div中resultdisplay.如果出现错误,我应该如何管理错误处理以重定向到完整视图?
码:
Ajax调用:
function GetFilteredValuesCallback(values) {
var data = JSON.stringify(values);
var url = '/Controller/Action';
$.ajax({
type: 'GET',
url: url,
data: { filter: data },
success: function (result) {
$('#resultDisplay').html(result);
}
});
}
Run Code Online (Sandbox Code Playgroud)
行动:
public ActionResult Action(string filter)
{
MyModel model = null;
try
{
// Do stuff with my model ...
throw new Exception("ERROR!");
}
catch (Exception ex)
{
// In case of error redirect to home page
return RedirectToAction("Index");
}
return PartialView("_PartialView", model);
}
Run Code Online (Sandbox Code Playgroud) asp.net ×3
javascript ×3
python ×3
f# ×2
jquery ×2
ajax ×1
angular ×1
angularjs ×1
asp.net-core ×1
asp.net-mvc ×1
blob ×1
c# ×1
controller ×1
css3 ×1
dbf ×1
django ×1
effect ×1
entity-model ×1
file ×1
file-upload ×1
filter ×1
firefox ×1
fparsec ×1
html ×1
ioerror ×1
media ×1
mysql ×1
new-operator ×1
parsing ×1
permissions ×1
python-2.7 ×1
python-3.3 ×1
redirect ×1
typescript ×1
ubuntu ×1
webpack ×1
webpack-2 ×1