小编Pra*_*eek的帖子

如何在Python中列出所有已安装的软件包及其版本?

有没有办法在Python中列出所有已安装的软件包及其版本?

我知道我可以进去python/Lib/site-packages看看存在哪些文件和目录,但我觉得这很尴尬.我正在寻找的东西类似于npm listNPM-LS.

python install packages

118
推荐指数
8
解决办法
25万
查看次数

控制台应用程序C#中的App.Config文件


我有一个控制台应用程序,我想在其中写一个文件的名称.

Process.Start("blah.bat");
Run Code Online (Sandbox Code Playgroud)

通常情况下,我会通过写文件的名称在Windows应用程序类似的东西'blah.bat'设置文件属性.
但是,在这里我没有找到任何设置文件,我添加了一个app.config用于相同的目的.

我不知道在app.config中写什么,这将导致我实现与Windows窗体类似的东西.

例如:在Windows窗体中.Process.Start(Properties.Settings.Default.BatchFile);
where BatchFile是属性中设置文件中的字符串.

c# console

89
推荐指数
3
解决办法
16万
查看次数

使用Prism.Forms,哪个IoC容器更好

我是在一个新的开始Prism.Forms的项目,我想知道其中的各种的IoC 容器(Autofac,Dryloc,NinjectUnity)将是最好的与前进.

我不知道这是否属实,但我在某处读到Unity已不再处于积极开发状态,因为这MEF是我用过的唯一IoC 容器,我不确定它是否可行.

与此同时,我知道很少或根本不知道Autofac,Dryloc或者Ninject.

请客观地提出任何建议,说明为什么你觉得一个人比其他人好,而不仅仅是"我用xxx "; 我想做出明智的决定.

ioc-container inversion-of-control xamarin.forms prism-6

22
推荐指数
1
解决办法
8167
查看次数

如何检查邮件中是否包含组合字符?

.

.

.

例如:กิิิิิิิิิิิิิิิิิิิิก้้้้้้้้้้้้้้้้้้้้ก็็็็็็็็็็็็็็็็็็็็ก็็็็็็็็็็็็็็็็็็็็กิิิิิิิิิิิิิิิิิิิิก้้้้้้้้้้้้้้้้้้้้ก็็็็็็็็็็็็็็็็็็็็กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้กิิิิิิิิิิิิิิิิิิิิก้้้้้้้้้้้้้้้้้้้้ก็็็็็็็็็็็็็็็็็็็็ก็็็็็็็็็็็็็็็็็็็็กิิิิิิิิิิิิิิิิิิิิก้้้้้้้้้้้้้้้้้้้้ก็็็็็็็็็ ็็็็็็็็็็กิิิิิิิิิิิิิิิิิิิิก้้้้้้้้้้้้้้้้้้้้(或任何"zalgo"文本)

我还没有找到任何方法来检查这些.我正在制作一种反垃圾邮件,我认为不需要保留这些反垃圾邮件,因为它们可能会滞后于用户,而且通常只是垃圾邮件.

我想做的是

if (getMessage().getRawContent().contains(combined character).delete();
Run Code Online (Sandbox Code Playgroud)

如果有人知道检查组合字符的简单方法,请发布!

如果您对我的要求感到困惑,我可以进一步解释,并在需要时显示更多示例.

java discord discord-jda

15
推荐指数
1
解决办法
472
查看次数

Python参数注释未解析的引用

为什么说它找不到我的课?为什么我要创建另一个具有相同名称的类,以使其不抱怨?

from typing import Dict


class WeekDay:

    def __init__(self, day_number, day_name):
        self.day_name = day_name
        self.day_number = day_number

    @staticmethod
    def get_week_days() -> Dict[str, WeekDay]:  # WeekDay unresolved reference error
        weekdays = {
            "monday": WeekDay(1, "Monday"),
            "tuesday": WeekDay(2, "Tuesday"),
            "wednesday": WeekDay(3, "Wednesday"),
            "thursday": WeekDay(4, "Thursday"),
            "friday": WeekDay(5, "Friday"),
            "saturday": WeekDay(6, "Saturday"),
            "sunday": WeekDay(7, "Sunday")
        }
        return weekdays
Run Code Online (Sandbox Code Playgroud)

python annotations python-3.x

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

TreeSet内部使用TreeMap,因此在使用Treeset时是否需要实现Hashcode方法?

我想知道这是什么意思时的javadocTreeSet

这个类实现了由TreeMap实例支持的Set接口?

在下面的示例中,我还没有实现该Hashcode方法,但仍按预期工作,即它能够对对象进行排序.请注意,我故意没有实现一致的Equals实现来检查TreeSet行为.

import java.util.TreeSet;


public class ComparisonLogic implements Comparable<ComparisonLogic>{

String field1;
String field2;

public String toString(){
    return field1+" "+field2;
}

ComparisonLogic(String field1,String field2){
    this.field1= field1;
    this.field2= field2;

}
public boolean equal(Object arg0){
    ComparisonLogic obj = (ComparisonLogic) arg0; 

    if(this.field1.equals(obj.field1))
        return true;
    else
        return false;
}

public int compareTo(ComparisonLogic arg0){
    ComparisonLogic obj = (ComparisonLogic) arg0;   
    return this.field2.compareToIgnoreCase(obj.field2);
}

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO …
Run Code Online (Sandbox Code Playgroud)

java collections hashcode treemap treeset

8
推荐指数
3
解决办法
2万
查看次数

如何在删除Realm文件之前在Android中备份Realm DB.有没有办法恢复备份文件?

我正在处理一个Android应用程序,我将删除Realm之前将新数据复制到Realm.有什么办法可以在删除之前备份数据并在使用时出现问题时将其还原realm.copyToRealm()吗?

android realm realm-database

8
推荐指数
2
解决办法
5019
查看次数

无法使用scrapy下载图像

我已经用python scrapy编写了一个脚本来从网站下载一些图像.当我运行我的脚本时,我可以.jpg在控制台中看到图像的链接(所有这些都是格式化的).但是,当我打开下载完成后应该保存图像的文件夹时,我什么都没有.我在哪里犯错误?

这是我的蜘蛛(我从崇高的文本编辑器运行):

import scrapy
from scrapy.crawler import CrawlerProcess

class YifyTorrentSpider(scrapy.Spider):
    name = "yifytorrent"

    start_urls= ['https://www.yify-torrent.org/search/1080p/']

    def parse(self, response):
        for q in response.css("article.img-item .poster-thumb"):
            image = response.urljoin(q.css("::attr(src)").extract_first())
            yield {'':image}

c = CrawlerProcess({
    'USER_AGENT': 'Mozilla/5.0',   
})
c.crawl(YifyTorrentSpider)
c.start()
Run Code Online (Sandbox Code Playgroud)

这是我settings.py为要保存的图像定义的内容:

ITEM_PIPELINES = {
    'scrapy.pipelines.images.ImagesPipeline': 1,
}
IMAGES_STORE = "/Desktop/torrentspider/torrentspider/spiders/Images"
Run Code Online (Sandbox Code Playgroud)

为了使事情更清楚:

  1. 我希望保存图像Imagesspider文件夹命名为我放在项目下的文件夹中torrentspider.
  2. Images文件夹的实际地址是C:\Users\WCS\Desktop\torrentspider\torrentspider\spiders.

这不是关于在items.py文件的帮助下成功运行脚本.因此,任何使用items.py文件进行下载的解决方案都不是我想要的.

python scrapy web-scraping python-3.x scrapy-spider

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

从BIP39(助记符)到BIP32(公钥/私钥)

我正在寻找开发一些代码,从助记符创建比特币私钥和公钥.我目前对这个过程的理解是:

entropy > nmemonic > seed > public/private keys > public address
Run Code Online (Sandbox Code Playgroud)

我在我的代码中使用了Trezor的nmemonic库moneywagon.

import string
from random import SystemRandom, randrange
from binascii import hexlify, unhexlify
from moneywagon import generate_keypair
from mnemonic import mnemonic

def gen_rand():
    foo = SystemRandom()
    length = 32
    chars = string.hexdigits
    return ''.join(foo.choice(chars) for _ in range(length))

mnemo = mnemonic.Mnemonic('english')

entropy = gen_rand()
# entropy = '00000000000000000000000000000000'

words = mnemo.to_mnemonic(unhexlify(entropy))
seed = hexlify(mnemo.to_seed(words, passphrase='apassphrase'))
address = generate_keypair('btc', seed)

print(words)  
print(seed)
print(address['public']['address'])
print(address['private']['hex'])
Run Code Online (Sandbox Code Playgroud)

如果你注释掉上面的熵行,并运行代码,你会得到: …

python cryptography mnemonics bitcoin cryptocurrency

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

Xamarin Forms 样式 - 支持多种目标类型

我最近更新到了最新的 Xamarin 表单预发行版 4.2 版本。我遇到的一个值得注意的重大变化是 - 假设我有以下风格:

    <Style x:Key="LightTextLabelStyle" TargetType="Label">
        <Setter Property="FontFamily" Value="{StaticResource TextLight}" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="TextColor" Value="{StaticResource greyishBrown}" />               
    </Style>
Run Code Online (Sandbox Code Playgroud)

在以前的版本中,跨度和标签都支持相同的目标“标签”。就像 - 这之前是有效的:

    <Label Margin="0,6,0,0">
         <Label.FormattedText>
              <FormattedString>
                    <Span Text="{Binding PriceText}" Style="{StaticResource LightTextLabelStyle}" FontSize="13" />
                     <Span Text="{Binding BidAmount, StringFormat=' {0:C0}' TargetNullValue=' Pending'}" Style="{StaticResource LightTextLabelStyle}" FontSize="13" />
              </FormattedString>
          </Label.FormattedText>
    </Label>
Run Code Online (Sandbox Code Playgroud)

Span 也支持针对 Label 的相同样式。然而现在在新版本中却没有了。

我的问题是:我们可以支持相同风格的 Label 和 Span 吗?我们不能为两者定位相同的风格吗?就像我尝试了以下但它无法编译:

    <Style x:Key="LightTextLabelStyle" TargetType="Label, Span">
        <Setter Property="FontFamily" Value="{StaticResource TextLight}" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="TextColor" Value="{StaticResource greyishBrown}" /> …
Run Code Online (Sandbox Code Playgroud)

xaml xamarin.forms xamarin.forms-styles

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