小编nis*_*ish的帖子

如何在本地浏览器上打开EC2实例端口

我在EC2实例的端口8983上运行solr.但是我无法在浏览器中使用以下命令打开solr界面:

http://public-dns:8983
Run Code Online (Sandbox Code Playgroud)

我也试过用:

http://ip.of.ec2.instance:8983
Run Code Online (Sandbox Code Playgroud)

但是他们没有工作.

如何在网络浏览器上打开它?

amazon-ec2 amazon-web-services

0
推荐指数
1
解决办法
4770
查看次数

Strtok用法,代码无效

我正在尝试使用strtok().以下是我写的一段代码.它不起作用,但", '"无限打印.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
char str[]="this, by the way, is a 'sample'";
char *tokens;
tokens = strtok(str, ", '");
//printf("%s\n",tokens);
//printf("%s\n", str);
while(tokens!=NULL)
{
    printf("%s\n", tokens);
    tokens = (NULL, ", '");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)

以下是strtok()手册页中的代码,完全正常.

#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="- This, a sample string.";
  char * pch;
  printf ("Splitting string \"%s\" into tokens:\n",str);
  pch = strtok (str," ,.-");
  while (pch != NULL)
  {
    printf …
Run Code Online (Sandbox Code Playgroud)

c strtok

-1
推荐指数
1
解决办法
1176
查看次数

将字符串转换为字典数组

我有一个以下形式的字符串:

"[{'status': 'Unshipped', 'city': 'New Delhi', 'buyer_name': 'xxx', 'name': 'xxx', 'countryCode': 'IN', 'payment_method': 'COD', 'y_id': 'xxx', 'phone': 'xxx', 'state': 'New Delhi', 'service': 'Expedited', 'amout': '425.00', 'address_1': 'xxx', 'address_2': 'xxx', 'postalCode': '110018', 'shipped_by_y': 'false', 'channel': 'MFN', 'order_type': 'StandardOrder'}, {'status': 'Unshipped', 'city': 'thane', 'buyer_name': 'xxx', 'name': 'xxx', 'countryCode': 'IN', 'payment_method': 'COD', 'y_id': 'xxx', 'phone': 'xxx', 'state': 'Maharashtra', 'service': 'Expedited', 'amout': '350.00', 'address_1': 'xxx', 'address_2': 'xxx', 'postalCode': '400607', 'shipped_by_y': 'false', 'channel': 'MFN', 'order_type': 'StandardOrder'}]\n"
Run Code Online (Sandbox Code Playgroud)

如何将此字符串转换为相应字典的数组.

我试图将字符串转换为JSON,然后加载JSON.但它仍然是一个字符串.

python json python-2.7

-1
推荐指数
1
解决办法
160
查看次数

Rails:语法错误,意外的keyword_ensure,期待$ end

以下代码给出错误:

/home/nish/staging/app/views/product_search/_products.html.erb:31: syntax error, unexpected keyword_ensure, expecting $end

<% if products.any? %>
<%= render :partial=> 'product_listing_feature', :locals => {:scope => scope, :scope_type => scope_type} %>
<ul class="products" data-hook class="products">
    <div id="ql_product"></div>
    <div class="page">
    <taxons.each do |taxon|>
      <% taxonProducts = Array.new %>
      <% products.each do |product| %>
        <%@ptaxon = product.get_taxonomy%>
        <%if @ptaxon == taxonomy%>
          <% taxonProducts.push(product) %>
        <% end %>
      <% end %>
    <%= render :partial=> 'product_listing', :locals=>{:collection=> taxonProducts} %>
    </div>
    <% end %>
</div>
</ul>
<% end %>
Run Code Online (Sandbox Code Playgroud)

我发现当<%end%> …

ruby ruby-on-rails

-3
推荐指数
1
解决办法
819
查看次数

C程序不打印

我写了以下程序:

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

void inttobusn(int val, int n, char* bus)
{
    int i;
    unsigned int digit;

    for (i=0; i < n; i++) {
            digit = pow(2, (n-1-i));
            if (digit <= val) {
                    val -= digit;
                    bus[i] = '1';
                    //printf("hello %c",bus[i]);
            } else {
                    bus[i] = '0';
            }       
     }
} 
main(){
  char* bus;
  inttobusn(37,8,bus);
  int i=0;
  //printf("%s",bus);
  for(i=0;i<12;i++){
      printf("%c",bus[i]);
  }
}
Run Code Online (Sandbox Code Playgroud)

但在运行时它不会打印数组的元素bus.它不打印任何东西.我无法弄清楚出了什么问题.有人可以指出吗?

c function

-4
推荐指数
1
解决办法
1777
查看次数