小编Shu*_*tra的帖子

SyntaxError:在严格模式下使用const?

我想用selenium-webdriver登录facebook.com.

var webdriver = require('selenium-webdriver'),
    By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until;

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build();

driver.get('https://www.facebook.com/login');
driver.findElement(By.id('email')).sendKeys('****');
driver.findElement(By.id('pass')).sendKeys('*****');
driver.findElement(By.id('loginbutton')).click();

driver.findElement(By.linkText('Settings')).then(function(element) {
  console.log('Yes, found the element');
}, function(error) {
  console.log('The element was not found, as expected');
});
driver.quit();
Run Code Online (Sandbox Code Playgroud)

这是错误的:

/home/shubham/node_modules/selenium-webdriver/index.js:25
const builder = require('./builder');
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/shubham/Music/amazon_login/test_22_4_16/sel_login.js:1:79)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js …
Run Code Online (Sandbox Code Playgroud)

selenium node.js selenium-webdriver

42
推荐指数
2
解决办法
11万
查看次数

类型错误:预期的类似字节的对象,而不是 str

我知道这个问题已经被问过很多次了,但请看一下我的问题。

我正在将base64图像数据从 angular发送到python 烧瓶,但是当我base64在烧瓶服务器(python3)上处理该数据时,它给了我错误

类型错误:预期的类似字节的对象,而不是 str

我的 Javascript 代码是:

window['__CANVAS'].toDataURL("image/png");
Run Code Online (Sandbox Code Playgroud)

上面一行的输出是:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUg....."
Run Code Online (Sandbox Code Playgroud)

我在烧瓶服务器上收到与字符串相同的数据。

使用以上 base 64 数据的 python 服务器上的代码是:

def convert_to_image(base64_code):
  image_64_decode = base64.decodebytes(base64_code)
  image_result = open('baseimage.jpg', 'wb')
  image_result.write(image_64_decode)
  img_rgb = cv2.imread('baseimage.jpg')
  return img_rgb
Run Code Online (Sandbox Code Playgroud)

然后它给出以下错误跟踪:

File "/home/shubham/py-projects/DX/Web/app/base64toimage.py", line 10, in convert_to_image    
  image_64_decode = base64.decodebytes(base64_code)
File "/usr/lib/python3.5/base64.py", line 552, in decodebytes    
  _input_type_check(s)
File "/usr/lib/python3.5/base64.py", line 521, in _input_type_check  
  raise TypeError(msg) from err 
TypeError: expected bytes-like object, not str
Run Code Online (Sandbox Code Playgroud)

如果我使用这个函数转换图像,上面的 python 函数工作正常

import base64

with open("t.png", …
Run Code Online (Sandbox Code Playgroud)

javascript python base64 angular6

9
推荐指数
1
解决办法
2万
查看次数

如果HTML/JavaScript中没有网页,请转到其他链接

当用户点击链接时,HTML或JavaScript中是否有任何选项,如果该链接可用则完成,如果没有,则进入另一个链接.

这是我的代码的一部分:

<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
 <ul>
    <li><a href="/returns"><span class="glyphicon glyphicon-log-in"></span> Returns</a></li>
    <li  class="active"><a href="/pay_reco" target="_blank"><span class="glyphicon glyphicon-log-in"></span> Payment Recouncillation </a></li>
    <li ><a href="/pay_get" target="_blank"><span class="glyphicon glyphicon-log-in"></span> Payment Get </a></li>
    <li><a href="/import"><span class="glyphicon glyphicon-log-in"></span> Import </a></li>
    <li>

<!-- Here I want to add  Two link in a href tag if first link does not 

available (web page not available) then it go to another link
        <!-- <object data="http:/127.0.0.1:9004" type="href" > -->
        <a target="_blank" href="http://127.0.0.1:9001">
            <span class="glyphicon glyphicon-log-in"></span>
             ComPare
        </a> …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

7
推荐指数
1
解决办法
428
查看次数

如何在ubuntu上安装Odoo 9?

我在5432和5433端口预装了postgres,postgres-9.3和pgadmin.

卸载它们然后尝试使用http://openies.com/blog/install-openerp-odoo-9-on-ubuntu-server-14-04-lts/安装odoo 9

本教程.

但是当我试着执行命令时

createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Run Code Online (Sandbox Code Playgroud)

然后它给出以下错误:

createuser:无法连接到数据库postgres:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受Unix域套接字"/var/run/postgresql/.s.PGSQL.5432"上的连接?

sudo netstat -nltp | grep 5432 没有显示任何结果.

的pg_hba.conf

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, …
Run Code Online (Sandbox Code Playgroud)

postgresql ubuntu openerp odoo

6
推荐指数
1
解决办法
1573
查看次数

仅在选项卡处于活动状态时加载数据

我将所有数据渲染到页面一次(在单个网址' http:// localhost:9111/sale / ').

并显示在该页面上的不同选项卡中.

<div class="tab-base">
             <!--Nav Tabs-->
             <ul class="nav nav-tabs">
                <li class="active">
                   <a data-toggle="tab" href="#demo-lft-tab-1">Daily Sale</a>
                </li>
                <li>
                   <a data-toggle="tab" href="#demo-lft-tab-2">Channel Wise Sale</a>
                </li>
                <li>
                   <a data-toggle="tab" href="#demo-lft-tab-3">Returns</a>
                </li>
               </ul>
            </div>
     <div class="tab-content">
<form method="POST" action="{% url 'sale' %}">
   {% csrf_token %}

   <div id="demo-lft-tab-1" class="tab-pane fade active in">
      <div class="panel-body">
         <table data-toggle="table">
            <thead >
               <tr>
                  <th data-align="center" data-sortable="true">Day</th>
                  <th data-align="center" data-sortable="true">Sale Value</th>
                  <th data-align="center" data-sortable="true">Quantity Sold</th>
               </tr>
            </thead>
            <tbody>
               {% for day, val, qty in sale_data %} …
Run Code Online (Sandbox Code Playgroud)

html javascript django ajax jquery

6
推荐指数
1
解决办法
2487
查看次数

错误:无法访问文件“$libdir/plpython2”:没有那个文件或目录

我正在运行 postgresql 9.4 ("PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14), 64-bit" )

当我尝试在 postgres SQL 中创建语言时:

create language plpythonu;
Run Code Online (Sandbox Code Playgroud)

然后它给出以下错误:

错误:无法访问文件“$libdir/plpython2”:没有这样的文件或目录 SQL 状态:58P01

我试试这个命令:

sudo apt-get install postgresql-contrib-9.4 postgresql-plpython-9.4 
Run Code Online (Sandbox Code Playgroud)

也尝试 sudo apt-get install postgresql-plpython-9.4 但没有运气。它的给出结果是:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages …
Run Code Online (Sandbox Code Playgroud)

python postgresql ubuntu

5
推荐指数
0
解决办法
3747
查看次数