使用 sed
$ sed -E 's#.*/([[:digit:]]+).*#\1#' input_file
15
代码中的第一个问题是您的第一行
从电子邮件导入消息
您从电子邮件导入消息,还将参数传递给具有相同名称的data_validation函数,然后在data_validation函数中返回false。如果返回false,则该功能将永远不会执行。
首先给出您导入的第一行的别名
尝试此
from email import message as msg
import os
import re
import html
import json
import telebot
import requests
import http.client
from pytube import *
from dotenv import load_dotenv
load_dotenv()
# Creating hiding, and using API Keys
API_KEY = os.getenv("API_KEY")
RAPID_KEY = os.getenv("RAPID_API")
bot = telebot.TeleBot(API_KEY)
# Creating a help message for guidance on how to use bot.
@bot.message_handler(commands=["start"])
def help(message):
# Trying to send help message, if unable to send, throw an error message for the user.
try:
bot.send_message(message.chat.id, "Use \"Youtube\" and the video name to search for a video.\n")
except:
bot.send_message(message.chat.id, "There was an error fetching help, the bot may be offline.\n")
# Checking data and seeing if the word "YouTube" was used in order to start the search
def data_validation(message):
query = message.text.split()
print(query)
if("youtube" not in query[0].lower()): # Set flag false if regular text
return False # if you return false, the function never will be executed
else:
return True
# Searching for youtube videos
# using RAPID API
@bot.message_handler(func=data_validation)
def search(message):
query = message.text.split()
print(query) # if function executed you see the query result
# Check if data is valid, and change variable to be lowercase for easy use.
if(data_validation(message) == True and query[0].lower() == "youtube"):
try:
if(data_validation(message) == True and query[1].lower() != "-d"):
# Removing the word "YouTube" and sending the results to the YouTube search engine.
for item in query[:]:
if(item.lower() == "youtube"):
query.remove(item)
search_query = ' '.join(query)
else:
pass #If it's not term we're looking to convert, ignore it.
# RAPID API for Youtube
try:
url = "https://youtube-search-results.p.rapidapi.com/youtube-search/"
querystring = {"q":search_query}
headers = {
"X-RapidAPI-Key": RAPID_KEY,
"X-RapidAPI-Host": "youtube-search-results.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring) # Grabbing response information from URL
request = json.loads(response.text) # Parsing json string for python use
# Testing to see if the RAPID API service responds and is online.
if(response.status_code == 503):
# If the service is not online, let the user know.
bot.send_message(message.chat.id, f"The RAPID API service appears to be offline try back later.\n")
if(response.status_code == 429):
# If the service has reached max quota for the day, let the user know.
bot.send_message(message.chat.id, f"Max quota reached, try back in 24 hours.\n")
# Grabbing first link from json text and sending direct url and title.
first_link = str((request["items"][0]["url"]))
bot.send_message(message.chat.id, f"{first_link}\n") # Sending first link that was queried.
# If there are no results found for the requested video, sending an error message to alert the user.
except:
bot.send_message(message.chat.id, "Unable to load video.\n")
except:
pass #ignoring if not the phrase we're looking for.
def test(message):
string = message.text.split()
print(string)
if(string[0] == "test" and data_validation(message) == True):
print("This is a test and i should be printed")
bot.send_message(message.chat.id, "Test message")
# Stay alive function for bot pinging / communication
bot.infinity_polling(1440)
pd.timestamp()
是Python的DateTime等效的熊猫,在大多数情况下可以与之互换。 DateTime库接受ISO 8601日期格式。
在Python ISO 8601中,日期以 yyyy-mm-ddthh:mm:ss.mmmmmm
格式表示。例如,2022年5月18日,表示为 2022-05-18T11:40:22.519222
。
-
yyyy
:四位数格式的一年 mm
:1-12 DD的月份:从1到31到31-
t
:这是分隔符字符那是在
日期和时间字段。这是一个可选参数,默认
“ t”的价值。 -
HH
:对于分钟的值 mm
:对于分钟的指定值ss
:对于秒的指定值mmmmmmm :对于指定的微秒
直接从pandas文档() 在这里 ):
基本上有三个针对构造函数的召集约定。主要形式接受四个参数。它们可以通过位置或关键字传递。
其他两种形式模仿了datetime.datetime的参数。他们
可以通过位置或关键字传递,但不会混合
一起。
示例
使用主要呼叫惯例:
这将转换一个类似日期的字符串的字符串,
>>> pd.Timestamp('2017-01-01T12')
Timestamp('2017-01-01 12:00:00')
的浮点
>>> pd.Timestamp(1513393355.5, unit='s')
Timestamp('2017-12-16 03:02:35.500000')
几秒钟的单位转换代表Unix epoch
>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific')
Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')
以 :
>>> pd.Timestamp(2017, 1, 1, 12)
Timestamp('2017-01-01 12:00:00')
>>> pd.Timestamp(year=2017, month=1, day=1, hour=12)
Timestamp('2017-01-01 12:00:00')
我们还在应用程序上遇到了这个问题,在a 真正的长期调试会话之后,我们发现它是由 apapter.sethasstableids(true)
>问题终于消失了。
希望它有帮助。
df['%increase_24'] = df.groupby('slug')['price_usd'].pct_change(1)
df['%increase_48'] = df.groupby('slug')['price_usd'].pct_change(2)
[出去]
slug datetime price_usd %increase_24 %increase_48
0 bitcoin 2022-06-01 00:00:00+00:00 29799.079714 NaN NaN
1 ethereum 2022-06-01 00:00:00+00:00 1823.569357 NaN NaN
2 bitcoin 2022-06-02 00:00:00+00:00 30467.487741 0.022430 NaN
3 ethereum 2022-06-02 00:00:00+00:00 1775.078620 -0.026591 NaN
4 bitcoin 2022-06-03 00:00:00+00:00 29704.391357 -0.025046 -0.003178
5 ethereum 2022-06-03 00:00:00+00:00 1834.150570 0.033278 0.005802
6 bitcoin 2022-06-04 00:00:00+00:00 29832.914225 0.004327 -0.020828
7 ethereum 2022-06-04 00:00:00+00:00 1801.609446 -0.017742 0.014946
8 bitcoin 2022-06-05 00:00:00+00:00 29906.661748 0.002472 0.006809
9 ethereum 2022-06-05 00:00:00+00:00 1805.204989 0.001996 -0.015781
10 bitcoin 2022-06-06 00:00:00+00:00 31364.535502 0.048747 0.051340
11 ethereum 2022-06-06 00:00:00+00:00 1858.546508 0.029549 0.031603
我希望我能理解您的问题。我试图修复程序,就像它将读取文件并列出文件中的数据列表。
我解决了一些问题;
-
对于
横向
函数,我添加了一个for循环,并使用%c
。打印了数据。
while(temp!= null){ for(i = 0; temp-> data [i]!='\ 0'; i ++){ printf(“%c \ n”,temp-> data [i]); } temp = temp-> next; }
-
我更改了
intertatend
这样的功能;void intertatend(文件* f,char* data)
自然而然,在主要功能中,称此函数的变化如;
insertAtEnd(ifp, result[i]);
顺便说一句,我的合格者希望我将 temp
以 char
的形式表示,它说这是第一次使用。似乎您在&
之后进入了一个空间。
insertAtEnd(ofp, &temp);
-
我将以下语句添加到
main
函数;argc- = optind; argv += optind;
-
我还更改了此
ifp = fopen(ifilename,“ r”);
使用此ifp = fopen(“ ifilename.txt”,“ r”);
>陈述。我打开了一个名为ifilename.txt
的文本文件,并在那里写了一些数据。
编辑:
好的,因此,如果要将字符串打印到输出文件,并且要单独打印单词,您将更改执行以下操作的代码:
-
我用数组更改了结构的数据,预期的最大线长度,尖锐定义
max_len
;结构节点 { char* data [max_len]; 结构节点 *prev; struct node *next; };
-
我再次更改了
interatend
函数,因为我在主函数中扫描了该文件,制作了字符串数组,将其发送到此功能并将其添加到列表的末尾。我在主要金属中使用了这件代码:char* result [count]; char* temp =(char*)malloc(sizeof(char)); while(fgets(temp,sizeof(temp),ifp)) { 结果[count] =(char*)malloc(sizeof(char)*20); strcpy(结果[count],temp); 插入(结果,计数); 计数++; }
count
是文件中的字符串数。我还将此数字发送到 intertatend
函数;
void insertAtEnd(char* data[], int size)
{
//Create a new node
struct node *newnode = (struct node*)malloc(sizeof(struct node));
newnode->data[size] = data[size];
if (newnode->data[size] != NULL) {
...
-
我想使用您在
main
函数中打开的输出文件,因此我发送了此文件并发送了count
-number of Strings--到打印功能<代码>横向像这样;void traverse(file *,int size) { int i; //列表为空 if(head == null){ printf(“ \ nlist为空\ n”); 返回; }; // else打印数据 struct节点* temp; temp = head; while(temp!= null){ for(i = 0; i&lt; size; i ++){ fputs(temp-&gt; data [i],of); temp = temp-&gt; next; } fprintf(of,“ \ n”); } }
同样在 main
函数中,调用此函数将更改为;
traverse(ofp, count);
相关ID仅在GitLab日志中或GitLab的HTTP 响应中找到。这也仅适用于GitLab的服务,并且是内部机械师。您无需做任何事情即可获得与日志或响应中出现的相关ID。如果您的工作或其他代码您写入使用 curl
与Gitlab通信,则您(不能)自己不提供相关ID。
例如,当Gitlab Runner向协调员(GitLab服务器)上的Jobs API提出后请求时,您将使用类似于GitLab日志中的以下日志:
{"content_type":"","correlation_id":"01234ABCDEFGHIJKLMNOPQRSTU","duration_ms":1,"host":"gitlab.example.com","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:0","remote_ip":"127.0.0.1","route":"^/api/v4/jobs/request\\z","status":204,"system":"http","time":"2022-06-30T00:17:40Z","ttfb_ms":1,"uri":"/api/v4/jobs/request","user_agent":"gitlab-runner 15.1.1 (15-1-stable; go1.17.7; linux/amd64)","written_bytes":0}
如果您是自载gitlab,则只需查看Gitlab的日志并可以访问其日志(通常是系统管理员可以通过在磁盘上查找它们)。如果您使用的是gitlab.com,则无法访问这些日志。
作为客户端,您可以在gitlab的HTTP 响应中的响应标头中看到相关ID。使用 curl
作为示例,您可以添加 - 冗长
标志以查看响应标头。
在这里,我们将 grep
x-request-id
使其更容易看到。
$ curl --verbose https://gitlab.com/api/v4/projects/278964 2> >(grep x-request-id)
< x-request-id: 01G6S0168KKRNVNM5610DRXVPW
查看libcurl文档,有一个看起来很有希望的变量(curl_trace) - 将其设置为1个工作中的1个似乎没有产生任何不同/附加的输出
在您的工作中产生任何不同/附加的输出设置变量,例如 curl_trace
不会影响跑步者和GitLab(1)之间的相互作用,因为跑步者环境/配置是从其运行的作业中隔离的,并且(2)跑步者不使用卷发; Gitlab Runner 。
还有其他方法可以哄骗跑步者提供相关ID?
tl; no。跑步者未从其向GitLab提出的请求记录HTTP响应标头。除非您修改跑步者的源代码来记录响应标头并将跑步者从修改后的源代码重新编译,否则这是不可能的。
您可以使用类似的内容:
SELECT * FROM
(
SELECT cdc.type, Switch(
type = "APPEND", 2,
type = "UPDATE", 3,
type = "DELETE", 4
) AS typeid, cdc.id, cdc.timestamp, cdc.product, cdc.price
FROM cdc
UNION
SELECT "Current" AS type, 1 AS typeid, sales.id, sales.timestamp, sales.product, sales.price
FROM sales
)
ORDER BY id, typeid
您可以在子征服和外部查询上都有其他查询子句,
您可以在内部查询中使用案例语句为每个事务类型设置typeID,然后通过TypeId
note 订购外部查询。 :查询写在MS访问中
似乎SDL2板条箱的文档是为已经知道SDL如何工作并且只想在Rust中使用它的人编写的。您可能想先完成几个教程……
再说一次,只有 point 带领我到正确的功能。
快速示例带有一些闪烁的点:
use rand::Rng;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Point;
use std::time::Duration;
pub fn main() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
.window("rust-sdl2 demo", 800, 600)
.position_centered()
.build()
.unwrap();
let mut canvas = window.into_canvas().build().unwrap();
let mut event_pump = sdl_context.event_pump().unwrap();
let mut i = 0;
let mut rng = rand::thread_rng();
'running: loop {
for event in event_pump.poll_iter() {
match event {
Event::Quit { .. }
| Event::KeyDown {
..
} => break 'running,
_ => {}
}
}
canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
i = (i + 1) % 255;
canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
let (w, h) = canvas.output_size().unwrap();
let mut points = [Point::new(0, 0); 256];
points.fill_with(|| Point::new(rng.gen_range(0..w as i32), rng.gen_range(0..h as i32)));
// For performance, it's probably better to draw a whole bunch of points at once
canvas.draw_points(points.as_slice()).unwrap();
canvas.present();
::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60)); // sloppy FPS limit
}
}
(由于解决了OP的问题,因此将其添加为正式答案)。
该错误在 getInitialQuestionList()
函数中,该功能当前包含一个无限环路 - 数组的长度永远不会增加。正如您所确定的那样,您在问题上使用错误的 .text
属性,而不是正确的 .questiontext
。
我如何发现
我复制并将您的代码粘贴到一个新的React Codesandbox中的问题,这向我展示了一条不错的错误消息,说明可能有无限的循环和功能中的确切行。不过,我只是没有足够长时间的时间来挖掘它,以弄清为什么无限循环会发生。
PS如果您在此处使用Typescript,则TS编译器可能会遇到此错误,并为您节省了很多麻烦。只是思考的食物。
因此,经过大量的研究,似乎班级库必须成为消费解决方案的一部分。否则,在类库中安装的软件包也必须安装在消费应用程序中。添加这些软件包后,该应用程序可以正常工作。希望这对别人有帮助。
您需要为每个文件夹创建新的存储提供商实例。像:
string contentContainer = "container1";
// Creates a new StorageProvider instance
var coreStorageProvider = new StorageProvider("Azure", "CMS.AzureStorage")
{
// Specifies the target container which should represent the site/codebase
CustomRootPath = contentContainer
};
// Maps a directory to the provider
StorageHelper.MapStoragePath("~/foo1", coreStorageProvider);
string contentContainer = "container2";
// Creates a new StorageProvider instance
var coreStorageProvider = new StorageProvider("Azure", "CMS.AzureStorage")
{
// Specifies the target container which should represent the site/codebase
CustomRootPath = contentContainer
};
// Maps a directory to the provider
StorageHelper.MapStoragePath("~/foo2", coreStorageProvider);
有问题的代码行包含多个属性和方法调用:
我建议通过在单独的代码行上声明它们中的每一个来破坏属性和方法调用。因此,您会发现有问题的电话。
无论如何,要找到是否存在共享商店中的此类文件夹,我建议您在所有子文件夹中迭代并获取其名称,因此您可能会以这种方式找到所需的文件夹。
The problematic line of code contains multiple property and method calls:
I'd recommend breaking the chain of property and method calls by declaring each of them on a separate line of code. Thus, you will find the problematic call.
Anyway, to find whether such folder exists in a shared store I'd suggest iterating over all subfolders and getting their names, so you may find the required folder following that way.
共享收件箱子文件文件未找到错误