我今天开始编程并且在Python中遇到了这个问题.这是相当愚蠢但我无法弄清楚如何做到这一点.当我使用print命令时,它会打印我想要的任何内容,然后转到另一行.例如:
print "this should be"; print "on the same line"
Run Code Online (Sandbox Code Playgroud)
应该返回:
这应该在同一条线上
而是返回:
这应该
在同一条线上
更确切地说,我试图创建一个程序if,告诉我一个数字是否是2
def test2(x):
if x == 2:
print "Yeah bro, that's tottaly a two"
else:
print "Nope, that is not a two. That is a (x)"
Run Code Online (Sandbox Code Playgroud)
但是它不会将最后一个识别(x)为输入的值,而是精确打印:"(x)"(带括号的字母).为了使它工作,我必须写:
print "Nope, that is not a two. That is a"; print (x)
Run Code Online (Sandbox Code Playgroud)
如果我输入test2(3)它给出:
不,那不是两个,就是
3
所以要么我需要让Python在打印行中识别我的(x)作为数字; 或打印两个单独的东西,但在同一条线上.在此先感谢并抱歉这样一个愚蠢的问题.
重要说明:我使用的是2.5.4版
另一个注意事项:如果我print "Thing" , print "Thing2"在第二次打印时说"语法错误".
我正在使用Prism 7.1导航框架(WPF)来获取一个对话框窗口,使用下面的配置弹出.这很成功.但是,我希望这个弹出窗口有标签,我可以来回导航.当我单击弹出框上的按钮试图在其中显示ViewA时,没有任何反应.通过设置断点,我看到导航路径被命中,并显示正确的视图名称.请参阅PopUpWindow.cs.但是,当它解析视图时,视图不会显示.更糟糕的是,没有错误!我很困惑为什么会这样.
假设我的命名空间是正确的,我做错了什么?
PrismApplication.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<ViewA>();
}
//Have tried register type, register type for navigation, etc etc.
Run Code Online (Sandbox Code Playgroud)
MainWindowViewModel.xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
Height="350" Width="525">
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" />
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
<StackPanel>
<Button Margin="5" Content="Raise Default Notification" Command="{Binding NotificationCommand}" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
MainWindowViewModel.cs
public MainWindowViewModel
{
public InteractionRequest<INotification> NotificationRequest { get; set; }
public DelegateCommand NotificationCommand { get; set; }
public MainWindowViewModel()
{
NotificationRequest = new InteractionRequest<INotification>();
NotificationCommand = new DelegateCommand(RaiseNotification); …Run Code Online (Sandbox Code Playgroud) 没有while循环可以做到吗?
static void Main(string[] args)
{
Console.WriteLine("Please enter a number");
int number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(" #" + Fibonacci(number));
}
public static int Fibonacci(int number)
{
if (number <= 1)
{
return 1;
}
else
{
return Fibonacci(number - 2) + Fibonacci(number - 1);
}
}
Run Code Online (Sandbox Code Playgroud)
我甚至无法Console.WriteLine在基本案例的主体中添加一个,因为它被执行[次数]次数; 不知道怎么做没有循环...