痴情

文章 评论 浏览 30

痴情 2025-02-21 00:24:28

我建议使用循环的,而不是字符串乘法,如果您的意图是100次打印同一件事;它会消耗较少的内存(不是100倍6个字符的字符串,但有了更大的数字,它可能会变得很重要),并且对休闲读者来说,意图更为明显:

var1 = "arun"
var2 = "86"

for _ in range(100):
    print(var1+var2)

如果您真的想构造一个除了插入\ n之外,在其中有Newlines的单字符串:

print(100*(var1+var2+'\n'))

另一个选项是将str.join与列表乘法使用:

print('\n'.join([var1+var2]*100))

生成器表达式:

print('\n'.join(var1+var2 for _ in range(100)))

或 上面的任何一个都带有sep参数print()

print(*(var1+var2 for _ in range(100)), sep='\n')

I'd suggest using a for loop rather than string multiplication if your intent is to print the same thing 100 times; it'll consume less memory (not that 100 times a 6-character string is a lot, but with a larger number it could become significant), and it makes the intent more obvious to the casual reader:

var1 = "arun"
var2 = "86"

for _ in range(100):
    print(var1+var2)

If you really wanted to construct a single string with newlines in it, apart from inserting \n before multiplying:

print(100*(var1+var2+'\n'))

another option would be to use str.join with list multiplication:

print('\n'.join([var1+var2]*100))

or a generator expression:

print('\n'.join(var1+var2 for _ in range(100)))

or to do either of the above with the sep parameter in print():

print(*(var1+var2 for _ in range(100)), sep='\n')

如何用多行打印输出

痴情 2025-02-20 09:53:41

类似?

df.groupby(['name','otherstuff1','otherstuff2'],as_index=False).sum()
Out[121]: 
   name  otherstuff1  otherstuff2  value1  value2
0  Jack         1.19         2.39       2       3
1  Luke         1.08         1.08       1       1
2  Mark         3.45         3.45       0       1

Something like ?(Assuming you have same otherstuff1 and otherstuff2 under the same name )

df.groupby(['name','otherstuff1','otherstuff2'],as_index=False).sum()
Out[121]: 
   name  otherstuff1  otherstuff2  value1  value2
0  Jack         1.19         2.39       2       3
1  Luke         1.08         1.08       1       1
2  Mark         3.45         3.45       0       1

与groupby一起使用sum()时,请保留其他列

痴情 2025-02-20 04:33:34

这就是我使用dplyr进行操作的方式:

library(dplyr) 

df <- data.frame(a = c(1,2,NA), 
                 b = c(5,NA,8))
filter(df, !is.na(a))

# output 
a  b
1 1  5
2 2 NA

This is how I would do it using dplyr:

library(dplyr) 

df <- data.frame(a = c(1,2,NA), 
                 b = c(5,NA,8))
filter(df, !is.na(a))

# output 
a  b
1 1  5
2 2 NA

如何在R中的数据框的特定列中删除Na值?

痴情 2025-02-19 20:10:58

您必须使用加入,

select EmplyoeeID, FirstName, ProjectName 
from EmployeeDetail 
join ProjectDetail on EmplyoeeDetailID = EmployeeID
where (select count(*) from ProjectDetail where EmplyoeeDetailID = EmployeeID) > 1

请在此处阅读有关加入的更多信息: https:// https://www.w3schools.com// sql/sql_join.asp

You must use a JOIN

select EmplyoeeID, FirstName, ProjectName 
from EmployeeDetail 
join ProjectDetail on EmplyoeeDetailID = EmployeeID
where (select count(*) from ProjectDetail where EmplyoeeDetailID = EmployeeID) > 1

Please read more about joins here: https://www.w3schools.com/sql/sql_join.asp

从有条件的2个表中选择值

痴情 2025-02-19 18:50:36

问题归因于其实现中的错误,如下所示: https:// github 。

​空格和创建双卷发括号,}}是关闭样式块并启动一个新的块,即:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
</style>
<style>
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>

The issue is due to a bug in their implementation, as documented here: https://github.com/hteumeuleu/email-bugs/issues/92

The easiest solution, since perhaps your minifying code may be removing whitespace and creating the double curly braces, }}, is to close the style block and start a new one, i.e.:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
</style>
<style>
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>

iOS Outlook应用仅在HTML电子邮件中允许单个媒体查询

痴情 2025-02-19 13:26:02

您可以使用计时器在主线程上节拍快照。这是一个示例

    @objc
    private func beginTapped() {
        print("Start time \(Date.now)")
        frameCount = 0
        let timer = Timer.scheduledTimer(timeInterval: 0.03, target: self, selector: #selector(takeSnapshot), userInfo: nil, repeats: true)
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
            timer.invalidate()
            print("Finished at \(Date.now) with \(self.frameCount) frames captured")
        })
    }
    
    @objc
    private func takeSnapshot() {
        frameCount += 1
        let render = UIGraphicsImageRenderer(size: selectedView.bounds.size)
        let _ = render.image { (context) in
            selectedView.drawHierarchy(in: selectedView.bounds, afterScreenUpdates: true)
        }
    }

,该示例

Start time 2022-07-01 04:20:01 +0000
Finished at 2022-07-01 04:20:07 +0000 with 180 frames captured

TimeInterval降低到0.01

Start time 2022-07-01 04:25:30 +0000
Finished at 2022-07-01 04:25:36 +0000 with 506 frames captured

在此期间的CPU使用率约为20%左右,并且该应用程序在我的琐碎示例中根本没有落后。

You can use a Timer to throttle the snapshots on the main thread. Here's an example

    @objc
    private func beginTapped() {
        print("Start time \(Date.now)")
        frameCount = 0
        let timer = Timer.scheduledTimer(timeInterval: 0.03, target: self, selector: #selector(takeSnapshot), userInfo: nil, repeats: true)
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
            timer.invalidate()
            print("Finished at \(Date.now) with \(self.frameCount) frames captured")
        })
    }
    
    @objc
    private func takeSnapshot() {
        frameCount += 1
        let render = UIGraphicsImageRenderer(size: selectedView.bounds.size)
        let _ = render.image { (context) in
            selectedView.drawHierarchy(in: selectedView.bounds, afterScreenUpdates: true)
        }
    }

which results in

Start time 2022-07-01 04:20:01 +0000
Finished at 2022-07-01 04:20:07 +0000 with 180 frames captured

Decreasing the timeInterval to 0.01 yields

Start time 2022-07-01 04:25:30 +0000
Finished at 2022-07-01 04:25:36 +0000 with 506 frames captured

CPU usage peaked around 20% during this time and the app did not lag at all in my trivial example.

从Uiview获取快照的最佳方法

痴情 2025-02-19 12:58:53

您拥有接口发布函数post()。我假设您想要接口道具中的前者,但是编译器和JS引擎会渗透后者。

重命名其中一个,以相同名称命名不同的事物很少是一个好主意。

You have interface Post and function Post(). I'm assuming you want the former in interface Props, but the compiler, and the JS engine, infers the latter.

Rename one of them, naming different things with the same name is rarely a good idea anyway.

类型错误:&#x27; post&#x27;指一个值,但在这里被用作类型。您的意思是&#x27; typeof post&#x27 ;?

痴情 2025-02-19 12:40:45
print("chain wheel calculator")                                                                                                                                                     
print("enter the little diameter in mm :")                                      
little_input = input()                                                          
print("enter the big diameter in mm :")                                         
big_input = input()                                                             
                                                                                
little_input = int(little_input)                                                
big_input = int(big_input)                                                      
                                                                                
num = 9                                                                         
                                                                                
def calculate(little_input, big_input, num):                                    
    num2 = num * big_input                                                      
    num3 = num2 / little_input                                                  
    rmin = num2 % little_input                                                  
    if rmin == 0:                                                               
        return num3                                                             
                                                                                
while num <= 100 :                                                              
    num3 = calculate(little_input, big_input, num)                              
    if num3:                                                                    
        print(num3)                                                             
    num += 1     

这应该起作用。我不确定您想要什么行为,但我认为您只想返回num3如果rmin == 0。如果rmin!= 0这将返回。因此,语句如果num3:检查num3不是none键入,然后打印结果值。您可以在此条件语句中添加您想做的任何您想做的事情。通常,Aviod混合范围像您之前所做的那样。

print("chain wheel calculator")                                                                                                                                                     
print("enter the little diameter in mm :")                                      
little_input = input()                                                          
print("enter the big diameter in mm :")                                         
big_input = input()                                                             
                                                                                
little_input = int(little_input)                                                
big_input = int(big_input)                                                      
                                                                                
num = 9                                                                         
                                                                                
def calculate(little_input, big_input, num):                                    
    num2 = num * big_input                                                      
    num3 = num2 / little_input                                                  
    rmin = num2 % little_input                                                  
    if rmin == 0:                                                               
        return num3                                                             
                                                                                
while num <= 100 :                                                              
    num3 = calculate(little_input, big_input, num)                              
    if num3:                                                                    
        print(num3)                                                             
    num += 1     

this should work. I am not sure what behaviour you want but I presume you only want to return num3 if rmin == 0. If rmin != 0 this will return None. So the statement if num3: checks if num3 is not None type and then prints the resulting value. You can add in whatever you wish to do to num3 within this conditional statement. Generally, aviod mixing scopes like you were doing before.

如何在凹陷之外带出一个变量?

痴情 2025-02-19 12:10:04

更改:

<xsl:param name="Doc" select="SL000000598" />

TO:

<xsl:param name="Doc" select="'SL000000598'" />

或:

<xsl:param name="Doc">SL000000598"</xsl:param>

您现在正在寻找一个名为SL00000000598的根元素。


请注意,如果您将其保留为原样,应该没有问题 - 或将其更改为&lt; xsl:param name =“ doc”/&gt; - 并将值作为运行时的参数传递为参数。失败的只是您的硬编码测试。

Change:

<xsl:param name="Doc" select="SL000000598" />

to:

<xsl:param name="Doc" select="'SL000000598'" />

or:

<xsl:param name="Doc">SL000000598"</xsl:param>

What you have now is looking for a root element named SL000000598.


Note that there should be no problem if you leave it as it is - or change it to <xsl:param name="Doc"/> - and pass the value as the parameter at runtime. It's only your hard-coded test that fails.

XSLT副本不匹配文档

痴情 2025-02-18 05:40:57

尝试几次并深入检查代码,我从未尝试在locked()函数中发送param。

我的意思是,我必须将param作为token_id in locked(token_id)之类的。

这对我有用,这解决了。

trying as several times and checking code deeply, I never tried to send param in locked() function.

I mean I have to send param as token_id in locked(token_id) like this.

This works for me and this was solved.

如何使用Web3py调用合同公共变量?

痴情 2025-02-17 07:53:28

因此,对于任何在这里有这个问题的人,您要去:所以问题是连接到语音通话。 确保您有这些意图

intents = discord.Intents.default()
intents.message_content = True
intents.voice_states = True

如果它仍然不起作用请确保已安装 pynacl已安装。您可以在终端中使用此代码pip install pynacl 进行此操作,但是您需要为此安装python 。那应该是修复

So for anybody having this issue here ya go: So the issue was connecting to the voice call. Make sure you have these intents

intents = discord.Intents.default()
intents.message_content = True
intents.voice_states = True

if it still doesnt work make sure you have PyNaCl installed. you can do it in a terminal with this code pip install pynacl you need to have python installed for this though. and that should be the fix

YouTube-DL和FFMPEG

痴情 2025-02-17 03:09:51

您可以使用 regex subroutines

\w+\s*(\((?:[^()]++|(?-1))*\))\s*=\s*\w+\s*({(?:[^{}]++|(?-1))*})

请参阅 REGEX DEMO

详细信息

  • \ w+ - 一个或多个单词chars
  • \ s* - 零或更多whitespaces
  • (\((((?:[^^^)) ()++ |(? - 1))*\)) - 配对嵌套括号之间的子弦
  • \ s*= \ s* - a =用零或更多的whitespaces包围的字符
  • \ w+\ s* - 一个或多个单词chars,零或更多whitespaces
  • ({(? 1))*}) - 配对嵌套卷曲括号之间的子字符串。

注意(?1)递归最新的捕获组模式。

You can use regex subroutines:

\w+\s*(\((?:[^()]++|(?-1))*\))\s*=\s*\w+\s*({(?:[^{}]++|(?-1))*})

See the regex demo.

Details:

  • \w+ - one or more word chars
  • \s* - zero or more whitespaces
  • (\((?:[^()]++|(?-1))*\)) - a substring between paired nested parentheses
  • \s*=\s* - a = char enclosed with zero or more whitespaces
  • \w+\s* - one or more word chars, zero or more whitespaces
  • ({(?:[^{}]++|(?-1))*}) - a substring between paired nested curly braces.

Note the (?-1) recurses the latest capturing group pattern.

将递归与小组递归

痴情 2025-02-16 22:07:11

我设置了以预设尺寸打开的窗口,因此我拿了所有需要的印刷品。

我检查一下是否正在找到所有图像,然后发现它们正确。但是现在我将其运行在Mac上,以相同大小的窗口打开窗口,但是,它找不到图像。

我不知道为什么,但是即使有相同的窗口尺寸,Mac上的图像也会较小:(

我打开了一个大小(1440,900)的窗口,并拍摄了2张登录按钮的图片。其他

大小。

  • 图片

I set the window to open at a preset size, so I took all the prints I needed.

I checked to see if I was finding all the images, and I was finding them just right. But now I put it to run on Mac, to open the window with the same size, however, it doesn't find the images.

I don't know why, but even with the same window size, the image appears smaller on Mac :(

I open a window with the size (1440, 900) and took 2 pictures of the Login button. 1 picture in Mac and the other in Windows.

The size of the pictures:

  • Mac = (207, 53)
  • Windows = (253, 73)

pyautogui位置(Mac和Windows)

痴情 2025-02-16 21:02:10

因此,在浏览了Kivy Discord Server(我建议使用Kivy的任何人)之后,我发现使用Hyturtle使用Plyer-S叉版本的解决方案正在正常工作。

为此,对于在同一问题上挣扎的任何人,将此主链接添加到buildozer要求中 - https://github.com/hyturtle/plyer/archive/master.zip 喜欢这样

requirements = python3,kivy, https://github.com/HyTurtle/plyer/archive/master.zip

,不要忘记运行'buildozer -v android call'命令,以删除先前安装的plyer版本,如果您有一个版本。

哇!

So after looking through Kivy Discord server (which I recommend to anyone who's using Kivy), I've found out that solution with using plyer-s fork version from HyTurtle is working.

To do so, for anyone who's struggling with the same issue, add this master link to buildozer requirments - https://github.com/HyTurtle/plyer/archive/master.zip like that

requirements = python3,kivy, https://github.com/HyTurtle/plyer/archive/master.zip

And dont forget to run 'buildozer -v android clean' command to remove previously installed plyer version if you had one.

Whoohoo!

Plyers GPS模块在Android 12设备上的问题

痴情 2025-02-16 16:48:21

mv-expander阵列。
parse 操作员,以从每个URL。

datatable(doc:dynamic)[dynamic([ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247155", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247154 ", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247160", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247156", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247159", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247157", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247158", "attributes": { "isLocked": false, "name": "Child" } } ])]
| mv-expand doc
| project doc.url
| parse doc_url with * "/" num:long
doc_urlhttps
:// fakelink/workitems/247155247155
https:// fakelink/workitems/247154247154
https:// fakelink/247159
fakelink/fakelink/247160 247160 247160
https:// 9https
: //fakelink/workItems/247157247157
https://fakelink/247158247158

mv-expand operator, to explode the array.
parse operator, to extract the number from each url.

datatable(doc:dynamic)[dynamic([ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247155", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247154 ", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247160", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247156", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247159", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247157", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247158", "attributes": { "isLocked": false, "name": "Child" } } ])]
| mv-expand doc
| project doc.url
| parse doc_url with * "/" num:long
doc_urlnum
https://fakelink/workItems/247155247155
https://fakelink/workItems/247154247154
https://fakelink/247160247160
https://fakelink/247156247156
https://fakelink/workItems/247159247159
https://fakelink/workItems/247157247157
https://fakelink/247158247158

Fiddle

循环通过查询以拉动KQL/Grafana中的子字样?

更多

推荐作者

眼泪淡了忧伤

文章 0 评论 0

corot39

文章 0 评论 0

守护在此方

文章 0 评论 0

github_3h15MP3i7

文章 0 评论 0

相思故

文章 0 评论 0

滥情空心

文章 0 评论 0

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