小编Mit*_*tul的帖子

我可以在 PowerShell 退出时将 PowerShell 历史记录写入文本文件吗?

我很想知道我们是否可以在 Powershell 中做到这一点。

使用 Out-File 命令,我们可以通过管道将输出写入文件。这样我就可以将我所有的历史命令发送到一个文本文件。

问题是我可以在每次退出时将我的历史命令发送到文本文件吗?
我不知道这是否会有很大帮助,但有时如果你写了一些衬垫并且你不小心退出了 PS 控制台,那么所有的历史命令都会被保存到一个文本文件中,就像最近的聊天对话一样。

powershell

2
推荐指数
1
解决办法
3421
查看次数

为什么我把这个0作为Python中(1/10)的答案?

我在Python 2.7 Interpreter中尝试这个.

>>> print 1/10  
0  
>>> print float(1/10)  
0.0  
>>> print 1/5  
0  
>>> a = 1/5  
>>> a  
0  
>>> float(a)  
0.0  
>>>   
Run Code Online (Sandbox Code Playgroud)

当我分开时,我想要一个浮点值.关于这个零输出背后的逻辑的任何想法,请让我知道如何正确地做到这一点.

python

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

我们可以使用Nullable(of T)来使用List <of T>吗?

在下面的示例代码中,我尝试将Nullable(of T)用于DateTime,并且我想使用与Dimensions属性相同的List(Dimension).

 Private _duedate As Nullable(Of DateTime)
        Public Property DueDate() As Nullable(Of DateTime)
            Get
                Return _duedate
            End Get
            Set(ByVal value As Nullable(Of DateTime))
                _duedate = value
            End Set
        End Property

   Private _dimensions As List(Of Dimension)
            Public Property Dimensions() As List(Of Dimension)
                Get
                    Return _dimensions
                End Get
                Set(ByVal value As List(Of Dimension))
                    _dimensions = value
                End Set
            End Property
Run Code Online (Sandbox Code Playgroud)

如果我们可以请求任何帮助我们如何做到这一点将不胜感激.

谢谢.

vb.net generics

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

Windows中不同的Python shell中"print"和"range"的工作方式不同(或根本没有)?

最近我开始在windows上学习python.我很困惑,因为它显示我在VS工具中为python和Iron Python控制台输出的方式.和PyScripter和IronPython有类似的区别.

print命令在IronPython控制台和Visual Studio中的Python 3.2 Interactive中的工作方式不同.

print("Hello") # works perfectly inside visual studio 
Hello
print "Hello"  # gives error when running ctrl+F5 
Invalid Syntax
print "Hello"  # works great inside IronPython console
Hello
Run Code Online (Sandbox Code Playgroud)

另外我注意到在PyScripter for windows中,下面的代码什么也没产生

range(6)
#nothing happens in PyScripter
range(6) #inside IronPython console works fine
[0,1,2,3,4,5]
Run Code Online (Sandbox Code Playgroud)

对这里发生了什么有什么想法吗?

更新:
在IronPython控制台中运行以下命令

>>>import sys
>>>sys.version
'2.7.1 <IronPython 2.7.1 <2.7.0.40) on .NET 4.0.30319.239)'
Run Code Online (Sandbox Code Playgroud)

PyScripter和VSTS for Python中的相同行为主窗口不产生输出(任何想法?运行PyScripter 2.4.3)和下面生成的解释器

'3.2.2 (default, sep 4 2011, 09:51:08) [....]'
Run Code Online (Sandbox Code Playgroud)

python

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

无法从类库项目中的App.Config访问AppSettings

我试图使用以下语法访问appSettings,我之前在我的许多网站项目中使用过它,但不是在类库项目中.在这个类库项目中,我甚至无法访问AppSettings键.有什么方法可以从我的班级访问AppSettings Key吗?类库项目的app.config或项目结构是否以不同的方式运行?

 Dim SharedDrive As String = ConfigurationManager.AppSettings("scriptsfolder")

<configuration>
  <appSettings>
    <add key="scriptsfolder" value="C:\BadTempScripts"/>
  </appSettings>
Run Code Online (Sandbox Code Playgroud)

我已经在System.Configuration中添加了Project Reference并在我的类中导入.当我运行我的代码时,它说:"对象未设置为任何对象的实例".

vb.net app-config

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

PowerShell返回SELECT*上的Length属性

我试图获得所有的字符串属性和方法.而不是>"1,2,3,4,5,6"| Get-Member只是出于好奇我尝试了以下命令,它给了我String对象的Length属性.我以为它会给我错误或没有输出.知道为什么这样做吗?或者PowerShell如何解释SELECT命令?

    PS C:>"1,2,3,4,5,6" | SELECT * 

    Length  
    -----------

    11
Run Code Online (Sandbox Code Playgroud)

powershell

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

标签 统计

powershell ×2

python ×2

vb.net ×2

app-config ×1

generics ×1