我一直在尝试使用tensorflow两天,现在在python2.7和3.4中反复安装和重新安装它.无论我做什么,我在尝试使用tensorflow.placeholder()时都会收到此错误消息
这是非常的样板代码:
tf_in = tf.placeholder("float", [None, A]) # Features
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我总会得到回溯:
Traceback (most recent call last):
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 2, in <module>
import tensorflow as tf
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 53, in <module>
tf_in = tf.placeholder("float", [None, A]) # Features
AttributeError: 'module' object has no attribute 'placeholder'
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
我想创建一个订单页面,其中包含两个选项卡下订单选项卡,我的订单选项卡.所以我创建了一个Order.js文件和另一个OrderContent.js文件.
Order.js
/* @flow */
import React from 'react'
import {
View,
StatusBar,
} from 'react-native'
import SplashScreen from 'react-native-splash-screen'
import HomeHeader from '../Components/HomeHeader'
import OrderContent from './OrderContent'
export default class OrdersScreen extends React.Component {
static navigationOptions = {
drawer: () => ({
label: 'Orders',
}),
}
static propTypes = {
navigation: React.PropTypes.object.isRequired,
}
componentDidMount() {
SplashScreen.hide()
}
render() {
return (
<View style={{flex: 1, backgroundColor: '#fff'}}>
<StatusBar
barStyle="light-content"
backgroundColor={'#202930'} />
<HomeHeader
title="Order Page"
navigation={this.props.navigation} /> …Run Code Online (Sandbox Code Playgroud) 我在一本书中看到了一段代码,如下:
x = 10;
if(x ==10) { // start new scope
int y = 20; // known only to this block
x = y * 2;
}
Run Code Online (Sandbox Code Playgroud)
代码和块都是一样的吗?
假设我正在尝试签出一组特定的git文件,例如app/*^(.tmpl).html,
如何把这个正则表达式扔进去 git checkout branch -- (regex)
我正在尝试在我的django应用中实施google oauth2身份验证.我按照文档按照所有步骤操作.
在浏览器地址栏上,如果我浏览此https://foo.bar.net/api/v1/auth/login/google-oauth2/网址,它会通过谷歌正确验证并返回google-auth-token到提到的redirect-url,然后获取auth-token并将其转换为普通令牌,然后发送以json格式提供给用户或前端.
但是如果我试图从我的js代码向上面提到的URL发出GET请求,它会显示出来
Reason: CORS header 'Access-Control-Allow-Origin' missing
Run Code Online (Sandbox Code Playgroud)
前端的完整回溯看起来像,
GET https://foo.bar.net/api/v1/auth/login/google-oauth2/ 302 Found 718ms
polyfil...ndle.js (line 7507)
GET https://accounts.google.com/o/oauth2/auth?client_...DW&response_type=code&scope=openid+email+profile 200 OK
Login Failed Response { _body=Event error, status=0, ok=false, more...}
main.bundle.js (line 367)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://accounts.google.com/o/oauth2/auth?client_id=kguygvh868697-khgkhvkgvkgkgv.apps.googleusercontent.com&redirect_uri=https://foo.bar.net/api/v1/auth/complete/google-oauth2/&state=Cbms1QhSQVzjO3xkjhkyuu&response_type=code&scope=openid+email+profile. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
Run Code Online (Sandbox Code Playgroud)
我搜索了谷歌,它提示我安装djang-CORS-headers.我已经安装并配置了上面的包.但是出现了同样的错误.
我的一部分settings.py看起来像,
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
]
INSTALLED_APPS = [
'django.contrib.admin', …Run Code Online (Sandbox Code Playgroud) 我正在尝试将数据字节列表写入CSV文件.由于它是一个字节字符串列表,我使用下面的代码:
with open(r"E:\Avinash\Python\extracting-drug-data\out.csv", "wb") as w:
writer = csv.writer(w)
writer.writerows(bytes(datas, 'UTF-8'))
Run Code Online (Sandbox Code Playgroud)
但它会导致以下错误:
TypeError:没有字符串参数的编码或错误
datas 是字节字符串列表.
print(datas)
Run Code Online (Sandbox Code Playgroud)
产量
[b'DB08873', b' MOLSDFPDBSMILESInChIView Structure \xc3\x97Structure for DB08873 (Boceprevir) Close', b'394730-60-0', b'LHHCSNFAOIFYRV-DOVBMPENSA-N', b'Organic acids and derivatives ', b'Food increases exposure of boceprevir by up to 65% relative to fasting state. However, type of food and time of meal does not affect bioavailability of boceprevir and thus can be taken without regards to food. \r\nTmax = 2 hours;\r\nTime to steady state, three times a day …Run Code Online (Sandbox Code Playgroud) 我想要运行下面出现错误的测试用例.
运行commond:python manage.py test
如果您想尝试删除测试数据库'test_project_management_db',请输入'yes',或者取消'no'取消:是为别名'default'销毁旧测试数据库...
Traceback (most recent call last):
File "manage.py", line 24, in <module>
execute_from_command_line(sys.argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 62, in handle
failures = test_runner.run_tests(test_labels)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/test/runner.py", line 601, in run_tests
old_config = self.setup_databases()
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/test/runner.py", line 546, …Run Code Online (Sandbox Code Playgroud) 我想对第3列中所有行的值求和.我该怎么做?
输入:
chr19 10 11
chr19 12 15
chr19 11 29
chr19 a0 20
Run Code Online (Sandbox Code Playgroud)
预期产量:
75
目前我正在开发一款运行在Google应用引擎顶部的django应用.模型领域之一看起来像,
picture = models.ImageField()
Run Code Online (Sandbox Code Playgroud)
但它在保存特定模型时显示以下错误
File "/django_projects/cityguide-backend/src/lib/django/db/models/fields/files.py", line 93, in save
self.name = self.storage.save(name, content, max_length=self.field.max_length)
File "/django_projects/cityguide-backend/src/lib/django/core/files/storage.py", line 63, in save
name = self._save(name, content)
File "/django_projects/cityguide-backend/src/lib/django/core/files/storage.py", line 248, in _save
fd = os.open(full_path, flags, 0o666)
File "/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 73, in fake_open
raise OSError(errno.EROFS, 'Read-only file system', filename)
OSError: [Errno 30] Read-only file system: u'/django_projects/backend/src/Screenshot_from_2014-04-18_190527.png'
Run Code Online (Sandbox Code Playgroud)
经过一些研究后我发现,GAE不支持对文件系统进行写操作.我想我需要使用GAE blobstore或Google Cloud存储.但我不知道如何将这些与django的模型整合在一起.
我尝试测试时出现以下错误 LoginComponent
PhantomJS 2.1.1 (Linux 0.0.0): Executed 3 of 55 (1 FAILED) (0 secs / 0.307 secs)
PhantomJS 2.1.1 (Linux 0.0.0) LoginComponent should create FAILED
Failed: Uncaught (in promise): Error: Template parse errors:
There is no directive with "exportAs" set to "ngForm" ("iv class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<form (ngSubmit)="login(f)" [ERROR ->]#f="ngForm">
<div class="card card-login">
<div class="card-header text-cen"): LoginComponent@5:38
Run Code Online (Sandbox Code Playgroud)
我的组件的一部分看起来像,
login.component.ts
export class LoginComponent {
isBusy: boolean = false;
user: User;
constructor(
private router: Router,
private notificationService: NotificationService,
private authService: AuthenticationService, …Run Code Online (Sandbox Code Playgroud) python ×5
django ×3
javascript ×3
angular ×1
awk ×1
cors ×1
django-tests ×1
git ×1
google-oauth ×1
jasmine ×1
java ×1
postgresql ×1
python-3.x ×1
react-native ×1
react-router ×1
reactjs ×1
regex ×1
tensorflow ×1
typescript ×1
unit-testing ×1