壹場煙雨

文章 评论 浏览 29

壹場煙雨 2025-02-21 01:03:40

您可以累积所有行,直到看到空白行并遇到空白后写入累积的字符串 -

with open('infile.txt', 'r') as to_read, open('outfile.txt', 'w') as to_write:
    acc_str = ''
    for line in to_read:
        if line.strip() == '':
            to_write.write(acc_str + '\n')
            acc_str = ''
        acc_str += line.strip() + ' '
    else:
        to_write.write(acc_str)

输出

 22-05-16 20:35:20 ABC:D UP:84.4,DN:84.3,Q=93 F: 35.7967 V: 0.50642 P:       0x1 Lev: 1483.64 
 22-05-16 21:30:00 ABC:D UP:84.4,DN:84.3,Q=93 F: 35.7967 V: 0.50642 P:       0x1 Lev: 1483.64 

You could accumulate all lines until you see a blank line and write the accumulated string once you encounter a blank -

with open('infile.txt', 'r') as to_read, open('outfile.txt', 'w') as to_write:
    acc_str = ''
    for line in to_read:
        if line.strip() == '':
            to_write.write(acc_str + '\n')
            acc_str = ''
        acc_str += line.strip() + ' '
    else:
        to_write.write(acc_str)

Output

 22-05-16 20:35:20 ABC:D UP:84.4,DN:84.3,Q=93 F: 35.7967 V: 0.50642 P:       0x1 Lev: 1483.64 
 22-05-16 21:30:00 ABC:D UP:84.4,DN:84.3,Q=93 F: 35.7967 V: 0.50642 P:       0x1 Lev: 1483.64 

python- txt组合线以字母开头

壹場煙雨 2025-02-20 20:57:58

原因似乎只有在加载页面后才通过AJAX请求加载表。使用无头浏览器可以解决此问题。

或其他选择是使用API​​提供商为;
https://rapidapi.com/scrapingbuddy-scrapingbuddy-default/api/scrapingbuddy/

以下代码显示PIC3游戏的表:

import requests

url = "https://scrapingbuddy.p.rapidapi.com/v1/scrape"

querystring = {"url":"https://www.njlottery.com/en-us/drawgames/pick3.html"}

headers = {
    "X-RapidAPI-Key": "XXX",
    "X-RapidAPI-Host": "XXX"
}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)

The reason seems that the tables are loaded via AJAX request only after the page loaded. Using a headless browser can solve this.

Or another option is using an API provider as;
https://rapidapi.com/scrapingbuddy-scrapingbuddy-default/api/scrapingbuddy/

The following code shows the tables of the pic3 game:

import requests

url = "https://scrapingbuddy.p.rapidapi.com/v1/scrape"

querystring = {"url":"https://www.njlottery.com/en-us/drawgames/pick3.html"}

headers = {
    "X-RapidAPI-Key": "XXX",
    "X-RapidAPI-Host": "XXX"
}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)

python网络刮擦表

壹場煙雨 2025-02-20 18:12:49

使用此公式将条件格式应用到所需范围(从单元C2开始)的范围:

=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

Apply a conditional formatting to the range desired (starting from cell C2) using this formula:

=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

即使第一个相邻单元格为空白,有条件的格式基于相邻的单元格值

壹場煙雨 2025-02-19 03:16:24

为了有条件输出HTML代码,您需要从PHP回声。这是我认为您想要的。我一直保持格式化

<?php
if( isset($_SESSION['username']) && !empty($_SESSION['username']))
  {echo '<a class="right" href="logout.php">Log Out</a>';}
if( isset($_SESSION['roles']) && $_SESSION['roles']===['Y'])
  {echo '<a class="right" href="userManagement.php">User Profile</a>';}
else
  {echo '<a class="right" href="login.php">Login</a>';
   echo '<a class="right" href="register.php">Register</a>';}
?>

To conditionally output HTML code you need to echo it from PHP. Here's what I think you want. I have kept your formatting

<?php
if( isset($_SESSION['username']) && !empty($_SESSION['username']))
  {echo '<a class="right" href="logout.php">Log Out</a>';}
if( isset($_SESSION['roles']) && $_SESSION['roles']===['Y'])
  {echo '<a class="right" href="userManagement.php">User Profile</a>';}
else
  {echo '<a class="right" href="login.php">Login</a>';
   echo '<a class="right" href="register.php">Register</a>';}
?>

管理员视图仅导航栏php

壹場煙雨 2025-02-18 11:31:14

这是因为您第一次在index.js文件中使用browserrouter两次在代码中应用,第二次在app.js文件中您必须从代码中删除browserrouter标签之一。

 
ReactDOM.render(<App />, document.getElementById('root'));

It's because you apply browserrouter two times in your code first time inside your index.js file and second in the app.js file you have to remove one of the browserrouter tag from your code

 
ReactDOM.render(<App />, document.getElementById('root'));

React App不喜欢屏幕上没有任何不喜欢的路由组件,只有白页

壹場煙雨 2025-02-18 06:23:23

嗯...在我看来,就像您在这里比较蚊子和大象。 RabbitMQ+Pika不是不是芹菜的替代品。但是,RabbitMQ+Pika可以帮助您实施(微型)服务,例如芹菜,如果您确实想要的话。

如果将RABBITMQ用作后端,则芹菜(实际上 kombu )将使用与皮卡类似的东西-Celery amqp 项目,与经纪人进行交流。

Erm... it seems to me like you are comparing mosquitoes and elephants here. RabbitMQ+Pika is not a replacement for Celery. However, RabbitMQ+Pika can help you implement a (miniature) service such as Celery, if that is really what you want.

If you use RabbitMQ as backend, Celery (actually kombu) will use something similar to Pika - the celery amqp project, to communicate with the broker.

将芹菜与RabbitMQ一起用作经纪人,而仅使用RabbitMQ&#x2B; PIKA用于异步任务,使用一个任务的优点

壹場煙雨 2025-02-18 02:45:41

stopPropagation()可防止当前事件的进一步传播,但仍在处理重定向到链接。如果您想阻止这些行为,
您可以使用destrest -default()方法:

const onDelete = (e) => {
    e.preventDefault();
    // e.nativeEvent.stopPropagation();
  };

The stopPropagation() prevents further propagation of the current event but redirecting to links are still processed. If you want to stop those behaviors,
you can use preventDefault() method :

const onDelete = (e) => {
    e.preventDefault();
    // e.nativeEvent.stopPropagation();
  };

React Mui芯片on偏离访问停止propagation方法

壹場煙雨 2025-02-18 02:28:40

如果/else用较短的东西,您是否希望替换

您可以使用:

tiltes[title] = titles.get(title, 0) + 1

Do you wish to replace you if/else block with something shorter?

You can use:

tiltes[title] = titles.get(title, 0) + 1

一切正常在这里正确。我们如何检查“标题”在字典中,如果我没有添加或附加任何内容

壹場煙雨 2025-02-17 08:07:02

解决方案#1

  1. 运行Windows PowerShell时,Admin
  2. 运行PIP安装命令以安装Python模块或升级PIP。

-----或----

解决方案#2

使用运行PIP安装 - 用户 frag

命令:python -m pip install-pip install-upgrade pip-用户

Solution #1

  1. Run Windows PowerShell as Admin
  2. Run the pip install command to install the python module or upgrade the pip.

---- OR ----

Solution #2

Run Pip Install with --user flag

Command: python -m pip install --upgrade pip --user

为什么我可以在Windows 10上安装带有PIP的Python软件包?

壹場煙雨 2025-02-17 07:37:11

这是一些代码

const jsonData = { "Page1": { "path": "/page1" }, "Page2": { "path": "/account/menu/page1" }, "Page3": { "items": { "Subpage1": { "path": "/account/menu/subpage1" }, "Subpage2": { "path": "/account/menu/subpage2" }, "Subpage3": { "path": "/account/menu/subpage3" } } }, "Page4": { "items": { "Subpage4": { "path": "/account/menu/subpage4" }, "Subpage5": { "path": "/account/menu/subpage5" }, } } };

const currentPageName = 'Subpage2';

const getThePageName = path => Object.keys(jsonData).reduce((acc, el) => {
  if (acc?.length) {
    return acc;
  }
  if (jsonData[el].hasOwnProperty('items')) {
    if (jsonData[el]?.items?.[currentPageName]?.path === path) {
      console.log(path, jsonData[el]?.items?.[currentPageName]?.path)
      acc = currentPageName;
    }
  } else {
    if (jsonData[el].path === path) {
      console.log(path, jsonData[el].path, path)
      acc = el;
    }
  }
  return acc;
}, undefined);

console.log("getThePageName", getThePageName("/account/menu/subpage2"));

here is some piece of code

const jsonData = { "Page1": { "path": "/page1" }, "Page2": { "path": "/account/menu/page1" }, "Page3": { "items": { "Subpage1": { "path": "/account/menu/subpage1" }, "Subpage2": { "path": "/account/menu/subpage2" }, "Subpage3": { "path": "/account/menu/subpage3" } } }, "Page4": { "items": { "Subpage4": { "path": "/account/menu/subpage4" }, "Subpage5": { "path": "/account/menu/subpage5" }, } } };

const currentPageName = 'Subpage2';

const getThePageName = path => Object.keys(jsonData).reduce((acc, el) => {
  if (acc?.length) {
    return acc;
  }
  if (jsonData[el].hasOwnProperty('items')) {
    if (jsonData[el]?.items?.[currentPageName]?.path === path) {
      console.log(path, jsonData[el]?.items?.[currentPageName]?.path)
      acc = currentPageName;
    }
  } else {
    if (jsonData[el].path === path) {
      console.log(path, jsonData[el].path, path)
      acc = el;
    }
  }
  return acc;
}, undefined);

console.log("getThePageName", getThePageName("/account/menu/subpage2"));

JS如何在嵌套对象中找到结果

壹場煙雨 2025-02-16 09:16:58

我认为,如果将类型添加到与期望的类型相匹配的TS代码中,您可能会对错误有更多的了解,并让TS编译器告诉您您的期望与计算类型的不同之处。

1月QuodaL.plainDate表示2022-01-01,1月.daysinmonth是一个数字(在这种情况下,31,因为2022年1月,有31天)。因此,这就是错误告诉您的:&lt; =操作员对temeral.plaindate的左侧和右手没有任何含义。数字的一面。 (“ 2022年1月1日”或小于“ 31”吗?很难说。)

同样,adddays是另一个temeral.plaindate表示2022-01-02(比1月晚1天,因为您使用add()方法向其添加了1天,因此使用++运算符也没有任何意义。 (在这里,似乎可以想象一个日期可能会向其添加1天;但事实并非如此,仅使用add()方法来完成添加。)

如果您要创建一个数字在一月份的天数匹配的DIV中,您可以考虑将数字索引从1到1月。daysinmonth

I think you would probably have more insight into the error if you added types to your TS code matching the types that you expect, and let the TS compiler tell you where your expectations differ from the types that it computes.

january is a Temporal.PlainDate denoting 2022-01-01, and january.daysInMonth is a number (in this case 31, because January 2022 has 31 days). So this is what the error is telling you: the <= operator doesn't have any meaning for a left-hand side of Temporal.PlainDate and a right-hand side of a number. (Is "January 1, 2022" more or less than "31"? Hard to say.)

Likewise, addDays is another Temporal.PlainDate denoting 2022-01-02 (1 day later than january, because you added 1 day to it using the add() method) and so using the ++ operator on it doesn't have any meaning either. (Here, it does seem conceivable that incrementing a date might add 1 day to it; but that's not the case, adding is only done with the add() method.)

If you want to create a number of divs that match the number of days in January, you might consider looping a number index from 1 to january.daysInMonth?

如何使用临时API在日历月的时间里循环循环

壹場煙雨 2025-02-16 07:22:44

希望这是您要实现的目标:

这是我所做的:我使用了HR而不是::之前,但这并不重要,
在您的情况下,以前是.progress_container的中心哪个高度包括文本所占据的空间,而不是将其放在父级的中心,将其放在圆圈的中心,如<代码> top:calc(circle_height/2)

这是我的更改:

import CheckIcon from "@mui/icons-material/Check";
import "./styles.css";

export default function App() {
  const steps = [1, 2, 3, 4, 5];
  return (
    <>
      <div class="container">
        <div class="progress-container">
          <hr/>
         
          {steps.map((val) => (
            <div>
              <div className={`circle ${val === 4 ? "active" : ""}`}>
                {val === 4 ? <CheckIcon sx={{ fontSize: "3rem" }} /> : null}
              </div>
              <div className="test">
                {val % 2 === 0
                  ? "Conservative"
                  : "Somewhat Conservative but it is okay"}
              </div>
            </div>
          ))}
        </div>
      </div>
    </>
  );
}



CSS


@import url("https://fonts.googleapis.com/css?family=Muli&display=swap");

.container {
  text-align: center;
}

.progress-container {
  display: flex;
  justify-content: space-between;

  position: relative;
  max-width: 100%;
  width: 700px;
}

hr{
  position:absolute;
  height: 4px;
  width: 90%;
  background: #000;
  top: calc(85px / 2);
  left: 50%;
  z-index: -1;
  transform: translate(-50%, -50%);

}

.progress {
  /* background-color: var(--line-border-fill); */
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  height: 4px;
  width: 0%;
  z-index: -1;
  transition: 0.4s ease;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: red;
}

.circle {
  background-color: #fff;
  color: #999;
  border-radius: 50%;
  height: 85px;
  width: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #767676;
  transition: 0.4s ease;
  cursor: pointer;
  font-size: 20px;
}

.circle.active {
  border-color: #3769ff;
  background-color: #3769ff;
  color: #ffffff;
}

.test {
  max-width: 85px;
}



*** .container的效果.container移动视图上的宽度***

enter image description here

hope this is what you aim to achieve :

this is what i did : i used hr instead of ::before but it doesnt matter,
in your case the before is at the center of .progress_container which height includes the space occupied by the text so instead of putting it at the center of the parent put it at the center of the circles like this top:calc(circle_height / 2 )

here are my changes:

import CheckIcon from "@mui/icons-material/Check";
import "./styles.css";

export default function App() {
  const steps = [1, 2, 3, 4, 5];
  return (
    <>
      <div class="container">
        <div class="progress-container">
          <hr/>
         
          {steps.map((val) => (
            <div>
              <div className={`circle ${val === 4 ? "active" : ""}`}>
                {val === 4 ? <CheckIcon sx={{ fontSize: "3rem" }} /> : null}
              </div>
              <div className="test">
                {val % 2 === 0
                  ? "Conservative"
                  : "Somewhat Conservative but it is okay"}
              </div>
            </div>
          ))}
        </div>
      </div>
    </>
  );
}



css


@import url("https://fonts.googleapis.com/css?family=Muli&display=swap");

.container {
  text-align: center;
}

.progress-container {
  display: flex;
  justify-content: space-between;

  position: relative;
  max-width: 100%;
  width: 700px;
}

hr{
  position:absolute;
  height: 4px;
  width: 90%;
  background: #000;
  top: calc(85px / 2);
  left: 50%;
  z-index: -1;
  transform: translate(-50%, -50%);

}

.progress {
  /* background-color: var(--line-border-fill); */
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  height: 4px;
  width: 0%;
  z-index: -1;
  transition: 0.4s ease;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: red;
}

.circle {
  background-color: #fff;
  color: #999;
  border-radius: 50%;
  height: 85px;
  width: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #767676;
  transition: 0.4s ease;
  cursor: pointer;
  font-size: 20px;
}

.circle.active {
  border-color: #3769ff;
  background-color: #3769ff;
  color: #ffffff;
}

.test {
  max-width: 85px;
}



*** effect of the .container width on mobile view ***

enter image description here

如何与Div一起垂直对齐文本?

壹場煙雨 2025-02-16 05:43:03

您应该将路线保留为/dogs并在实际调用查询时提供查询参数

router.get('/dogs', breedAndNameController.fetch);

,然后提出请求为/dogs?breed = golden&amp; name = rex = rex

You should keep your route as /dogs and supply the query params when you actually call the query

router.get('/dogs', breedAndNameController.fetch);

and then you make a request to as /dogs?breed=GOLDEN&name=rex

打字稿 - 如何使用参数创建获取端点?

壹場煙雨 2025-02-16 04:59:35

发生错误,因为您不能保证x_train,y_train,y_test和y_test数据是np.array()。因此,请查看这些变量,然后检查它们是否在预期的dtype上还是在数组中。在这里,ia smack on。

train_x = np.asarray(train_x).astype('int32')

The error is caused, because you are not guaranteeing that x_train,y_train,y_test and y_test data is a np.array(). So go take a look at those variables and check if they are on the expected dtype or in a array. Here i a sample on how.

train_x = np.asarray(train_x).astype('int32')

ValueError:未能找到可以处理输入的数据适配器:&lt; class&#x27; exponents_processing_batches.sequence_train&gt;

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文